5 modprobe -q af_packet # For DHCP
10 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
11 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
13 if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
14 [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
18 # support for Syslinux IPAPPEND parameter
19 # it sets the BOOTIF variable on the kernel parameter
23 # pxelinux sets BOOTIF to a value based on the mac address of the
24 # network card used to PXE boot, so use this value for DEVICE rather
25 # than a hard-coded device name from initramfs.conf. this facilitates
26 # network booting when machines may have multiple network cards.
27 # pxelinux sets BOOTIF to 01-$mac_address
29 # strip off the leading "01-", which isn't part of the mac
33 # convert to typical mac address format by replacing "-" with ":"
38 if [ -z "$bootif_mac" ]
42 bootif_mac="$bootif_mac:$x"
47 # look for devices with matching mac address, and set DEVICE to
48 # appropriate value if match is found.
50 for device in /sys/class/net/*
52 if [ -f "$device/address" ]
54 current_mac=$(cat "$device/address")
56 if [ "$bootif_mac" = "$current_mac" ]
65 # if ethdevice was not specified on the kernel command line
66 # make sure we try to get a working network configuration
67 # for *every* present network device (except for loopback of course)
68 if [ -z "$ETHDEVICE" ] ; then
69 echo "If you want to boot from a specific device use bootoption ethdevice=..."
70 for device in /sys/class/net/*; do
72 if [ "$dev" != "lo" ] ; then
73 ETHDEVICE="$ETHDEVICE $dev"
78 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
79 for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
80 devlist="$devlist $device"
83 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
84 # an endless loop; if execution fails give it two further tries, that's
85 # why we use '$devlist $devlist $devlist' for the other for loop
86 for dev in $devlist $devlist $devlist ; do
87 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
88 ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
90 sleep "$ETHDEV_TIMEOUT" ; sleep 1
91 if [ -r /proc/"$jobid"/status ] ; then
92 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
96 # if configuration of device worked we should have an assigned
97 # IP address, if so let's use the device as $DEVICE for later usage.
98 # simple and primitive approach which seems to work fine
99 if ifconfig $dev | grep -q 'inet.*addr:' ; then
106 for interface in ${DEVICE}; do
107 ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
108 [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
109 if [ "$IPV4ADDR" != "0.0.0.0" ]
116 for interface in ${DEVICE}; do
117 # source relevant ipconfig output
118 OLDHOSTNAME=${HOSTNAME}
119 [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
120 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
123 if [ -n "${interface}" ]
125 HWADDR="$(cat /sys/class/net/${interface}/address)"
128 if [ ! -e "/etc/resolv.conf" ]
130 echo "Creating /etc/resolv.conf"
132 if [ -n "${DNSDOMAIN}" ]
134 echo "domain ${DNSDOMAIN}" > /etc/resolv.conf
135 echo "search ${DNSDOMAIN}" >> /etc/resolv.conf
138 for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
140 if [ -n "$i" ] && [ "$i" != 0.0.0.0 ]
142 echo "nameserver $i" >> /etc/resolv.conf
147 # Check if we have a network device at all
148 if ! ls /sys/class/net/"$interface" > /dev/null 2>&1 && \
149 ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
150 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
151 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
152 ! ls /sys/class/net/ra0 > /dev/null 2>&1
154 panic "No supported network device found, maybe a non-mainline driver is required."