7 if [ -n "${NONETWORKING}" ]; then
11 modprobe af_packet # req'd for DHCP
14 # (this /might/ be required for firmware loading to complete)
15 if grep -q noudev /proc/cmdline; then
16 log_begin_msg "Networking: Skipping udev as requested via bootoption noudev."
22 if [ -n "${IP}" ]; then
23 # call into initramfs-tools provided network setup functions, so basic
25 log_begin_msg "Networking: Waiting for basic network to come up..."
29 # prepare a new /etc/network/interfaces file (and, possibly, a new /etc/resolv.conf)
30 IFFILE="/root/etc/network/interfaces"
31 if [ -L /root/etc/resolv.conf ] ; then
32 # assume we have resolvconf
33 RESOLVCONF=/root/etc/resolvconf/resolv.conf.d/base
35 RESOLVCONF="/root/etc/resolv.conf"
38 # config for loopback networking
40 # Initially generated on boot by initramfs' 23networking.
43 iface lo inet loopback
49 # generate config for each present network device
50 for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*; do
51 [ -e ${interface} ] || continue
52 interface=$(basename ${interface})
55 # NODHCP or a previously run ipconfig mean that ifupdown should never
56 # touch this interface (IP-stack wise).
57 netconfig=/run/net-${interface}.conf
58 if [ -n "$NODHCP" ] || [ -e "${netconfig}" ]; then
62 # if boot option "nodhcp" is set but also boot option "dhcp" is
63 # set, then dhcp should win over it as we default to dhcp and if
64 # nodhcp is used as default boot option but "dhcp" is added then it
65 # would be confusing to not get a working network setup
66 if [ "$DHCP" = "true" ] ; then
71 allow-hotplug ${interface}
72 iface ${interface} inet ${method}
75 # DNS for resolvconf and /etc/resolv.conf
76 if [ -e "${netconfig}" ]; then
78 if [ -n "${DNSDOMAIN}" ]; then
79 echo " dns-search ${DNSDOMAIN}" >> $IFFILE
81 # make sure we don't have any 0.0.0.0 nameservers
83 for IPV4DNS in ${IPV4DNS0} ${IPV4DNS1}; do
84 [ -n "${IPV4DNS}" ] || continue
85 [ "${IPV4DNS}" != "0.0.0.0" ] || continue
86 IPV4DNSLIST="${IPV4DNSLIST}${IPV4DNS} "
88 if [ -n "${IPV4DNSLIST}" ]; then
89 echo " dns-nameservers ${IPV4DNSLIST}" >> $IFFILE
90 for IPV4DNS in ${IPV4DNSLIST}; do
91 echo "nameserver ${IPV4DNS}" >> $RESOLVCONF
96 if [ -z "$NODHCPHOSTNAME" -a -n "$HOSTNAME" ]; then
97 echo $HOSTNAME > /root/etc/hostname
100 unset DEVICE IPV4ADDR IPV4BROADCAST IPV4NETMASK IPV4GATEWAY IPV4DNS0 IPV4DNS1 HOSTNAME DNSDOMAIN NISDOMAIN ROOTSERVER ROOTPATH filename
101 unset IPV4DNS IPV4DNSLIST
107 if [ -n "$DNSSERVER1" ]
109 # disable any existing entries
110 if [ -r $RESOLVCONF ]
112 sed -i 's/nameserver/# nameserver/' $RESOLVCONF
114 for i in $DNSSERVER1 $DNSSERVER2
116 echo "nameserver $i" >> $RESOLVCONF