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
70 if [ -n "$VLANS" ] ; then
73 # vlan=<vid>:<phydevice>
74 for line in $(echo $VLANS | sed 's/ /\n'/) ; do
78 if [ -n "$vlandev" ] && [ -n "$vlanid" ] ; then
81 vlan_raw_dev=$interface
82 interface="${vlandev}.${vlanid}"
89 if [ -n "$vlan_raw_dev" ] ; then
92 iface ${interface} inet ${method}
93 vlan-raw-device $vlan_raw_dev
97 allow-hotplug ${interface}
98 iface ${interface} inet ${method}
102 unset vlandev vlanid vlan_raw_dev # unset variables to have clean state for next device
104 # DNS for resolvconf and /etc/resolv.conf
105 if [ -e "${netconfig}" ]; then
107 if [ -n "${DNSDOMAIN}" ]; then
108 echo " dns-search ${DNSDOMAIN}" >> $IFFILE
110 # make sure we don't have any 0.0.0.0 nameservers
112 for IPV4DNS in ${IPV4DNS0} ${IPV4DNS1}; do
113 [ -n "${IPV4DNS}" ] || continue
114 [ "${IPV4DNS}" != "0.0.0.0" ] || continue
115 IPV4DNSLIST="${IPV4DNSLIST}${IPV4DNS} "
117 if [ -n "${IPV4DNSLIST}" ]; then
118 echo " dns-nameservers ${IPV4DNSLIST}" >> $IFFILE
119 for IPV4DNS in ${IPV4DNSLIST}; do
120 echo "nameserver ${IPV4DNS}" >> $RESOLVCONF
125 if [ -z "$NODHCPHOSTNAME" -a -n "$HOSTNAME" ]; then
126 echo $HOSTNAME > /root/etc/hostname
129 unset DEVICE IPV4ADDR IPV4BROADCAST IPV4NETMASK IPV4GATEWAY IPV4DNS0 IPV4DNS1 HOSTNAME DNSDOMAIN NISDOMAIN ROOTSERVER ROOTPATH filename
130 unset IPV4DNS IPV4DNSLIST
136 if [ -n "$DNSSERVER1" ]
138 # disable any existing entries
139 if [ -r $RESOLVCONF ]
141 sed -i 's/nameserver/# nameserver/' $RESOLVCONF
143 for i in $DNSSERVER1 $DNSSERVER2
145 echo "nameserver $i" >> $RESOLVCONF