7 if [ -n "${NONETWORKING}" ]; then
11 log_begin_msg "Preconfiguring Grml networking"
13 modprobe af_packet # req'd for DHCP
16 # (this /might/ be required for firmware loading to complete)
17 if grep -q noudev /proc/cmdline; then
18 log_begin_msg "Networking: Skipping udev as requested via bootoption noudev."
24 if [ -n "${IP}" ]; then
25 # call into initramfs-tools provided network setup functions, so basic
27 log_begin_msg "Networking: Waiting for basic network to come up..."
31 # prepare a new /etc/network/interfaces file (and, possibly, a new /etc/resolv.conf)
32 IFFILE="/root/etc/network/interfaces"
33 if [ -L /root/etc/resolv.conf ] ; then
34 # assume we have resolvconf
35 RESOLVCONF=/root/etc/resolvconf/resolv.conf.d/base
37 RESOLVCONF="/root/etc/resolv.conf"
40 # config for loopback networking
42 # Initially generated on boot by initramfs,
43 # interfaces(5) file used by ifup(8) and ifdown(8)
45 # Include files from /etc/network/interfaces.d:
46 source /etc/network/interfaces.d/*
49 iface lo inet loopback
55 # generate config for each present network device
56 for interface in /sys/class/net/* ; do
57 [ -e ${interface} ] || continue
58 interface=$(basename ${interface})
59 [ "${interface}" = "lo" ] && continue
62 # NODHCP or a previously run ipconfig mean that ifupdown should never
63 # touch this interface (IP-stack wise).
64 netconfig=/run/net-${interface}.conf
65 if [ -n "$NODHCP" ] || [ -e "${netconfig}" ]; then
69 # if boot option "nodhcp" is set but also boot option "dhcp" is
70 # set, then dhcp should win over it as we default to dhcp and if
71 # nodhcp is used as default boot option but "dhcp" is added then it
72 # would be confusing to not get a working network setup
73 if [ "$DHCP" = "true" ] ; then
77 if [ -n "$VLANS" ] ; then
80 # vlan=<vid>:<phydevice>
81 for line in $(echo $VLANS | sed 's/ /\n'/) ; do
85 if [ -n "$vlandev" ] && [ -n "$vlanid" ] ; then
88 vlan_raw_dev=$interface
89 interface="${vlandev}.${vlanid}"
96 if [ -n "$vlan_raw_dev" ] ; then
99 iface ${interface} inet ${method}
100 vlan-raw-device $vlan_raw_dev
103 cat >> $IFFILE << EOF
104 allow-hotplug ${interface}
105 iface ${interface} inet ${method}
109 unset vlandev vlanid vlan_raw_dev # unset variables to have clean state for next device
111 # DNS for resolvconf and /etc/resolv.conf
112 if [ -e "${netconfig}" ]; then
114 if [ -n "${DNSDOMAIN}" ]; then
115 echo " dns-search ${DNSDOMAIN}" >> $IFFILE
117 # make sure we don't have any 0.0.0.0 nameservers
119 for IPV4DNS in ${IPV4DNS0} ${IPV4DNS1}; do
120 [ -n "${IPV4DNS}" ] || continue
121 [ "${IPV4DNS}" != "0.0.0.0" ] || continue
122 IPV4DNSLIST="${IPV4DNSLIST}${IPV4DNS} "
124 if [ -n "${IPV4DNSLIST}" ]; then
125 echo " dns-nameservers ${IPV4DNSLIST}" >> $IFFILE
126 for IPV4DNS in ${IPV4DNSLIST}; do
127 echo "nameserver ${IPV4DNS}" >> $RESOLVCONF
132 if [ -z "$NODHCPHOSTNAME" -a -n "$HOSTNAME" ]; then
133 echo $HOSTNAME > /root/etc/hostname
136 unset DEVICE IPV4ADDR IPV4BROADCAST IPV4NETMASK IPV4GATEWAY IPV4DNS0 IPV4DNS1 HOSTNAME DNSDOMAIN NISDOMAIN ROOTSERVER ROOTPATH filename
137 unset IPV4DNS IPV4DNSLIST
143 if [ -n "$DNSSERVERS" ]
145 # disable any existing entries
146 if [ -r $RESOLVCONF ]
148 sed -i 's/nameserver/# nameserver/' $RESOLVCONF
152 echo "nameserver $i" >> $RESOLVCONF