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
45 iface lo inet loopback
51 # generate config for each present network device
52 for interface in /sys/class/net/* ; do
53 [ -e ${interface} ] || continue
54 interface=$(basename ${interface})
55 [ "${interface}" = "lo" ] && continue
58 # NODHCP or a previously run ipconfig mean that ifupdown should never
59 # touch this interface (IP-stack wise).
60 netconfig=/run/net-${interface}.conf
61 if [ -n "$NODHCP" ] || [ -e "${netconfig}" ]; then
65 # if boot option "nodhcp" is set but also boot option "dhcp" is
66 # set, then dhcp should win over it as we default to dhcp and if
67 # nodhcp is used as default boot option but "dhcp" is added then it
68 # would be confusing to not get a working network setup
69 if [ "$DHCP" = "true" ] ; then
73 if [ -n "$VLANS" ] ; then
76 # vlan=<vid>:<phydevice>
77 for line in $(echo $VLANS | sed 's/ /\n'/) ; do
81 if [ -n "$vlandev" ] && [ -n "$vlanid" ] ; then
84 vlan_raw_dev=$interface
85 interface="${vlandev}.${vlanid}"
92 if [ -n "$vlan_raw_dev" ] ; then
95 iface ${interface} inet ${method}
96 vlan-raw-device $vlan_raw_dev
100 allow-hotplug ${interface}
101 iface ${interface} inet ${method}
105 unset vlandev vlanid vlan_raw_dev # unset variables to have clean state for next device
107 # DNS for resolvconf and /etc/resolv.conf
108 if [ -e "${netconfig}" ]; then
110 if [ -n "${DNSDOMAIN}" ]; then
111 echo " dns-search ${DNSDOMAIN}" >> $IFFILE
113 # make sure we don't have any 0.0.0.0 nameservers
115 for IPV4DNS in ${IPV4DNS0} ${IPV4DNS1}; do
116 [ -n "${IPV4DNS}" ] || continue
117 [ "${IPV4DNS}" != "0.0.0.0" ] || continue
118 IPV4DNSLIST="${IPV4DNSLIST}${IPV4DNS} "
120 if [ -n "${IPV4DNSLIST}" ]; then
121 echo " dns-nameservers ${IPV4DNSLIST}" >> $IFFILE
122 for IPV4DNS in ${IPV4DNSLIST}; do
123 echo "nameserver ${IPV4DNS}" >> $RESOLVCONF
128 if [ -z "$NODHCPHOSTNAME" -a -n "$HOSTNAME" ]; then
129 echo $HOSTNAME > /root/etc/hostname
132 unset DEVICE IPV4ADDR IPV4BROADCAST IPV4NETMASK IPV4GATEWAY IPV4DNS0 IPV4DNS1 HOSTNAME DNSDOMAIN NISDOMAIN ROOTSERVER ROOTPATH filename
133 unset IPV4DNS IPV4DNSLIST
138 echo '# Support overriding defaults:' >> $IFFILE
139 echo 'source /etc/network/interfaces.d/*' >> $IFFILE
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