[Patch] Assign the NIC via MAC address for PXE booting
Modern server almost has 2 or more network cards, and sometimes it's
annoying when PXE booting a Debian live system if the NIC is not known.
It would be useful if there is a boot parameter can be used to assign
the NIC via Mac address for PXE to boot from.
Attached please find the patch to assign the NIC via Mac address for PXE
booting.
For example, if
nicif=fc:aa:bb:cc:dd:ee
is assigned, then when PXE booting on that machine, the NIC with Mac
address "fc:aa:bb:cc:dd:ee" will be used to PXE boot from.
My 2 cents.
Steven
--
Steven Shiau <steven _at_ stevenshiau org>
Public Key Server PGP Key ID: 4096R/47CF935C
Fingerprint: 0240 1FEB 695D 7112 62F0 8796 11C1 12DA 47CF 935C
--- 9990-select-eth-device.sh.orig 2016-05-11 21:44:15.000000000 +0800
+++ 9990-select-eth-device.sh.new 2016-06-17 11:26:30.606576483 +0800
@@ -59,6 +59,29 @@
echo "Found live-netdev parameter, forcing to to use network device $NETDEV."
return
;;
+ nicif=*)
+ NICDEVICE="${ARGUMENT#nicif=}"
+ echo "NIC interface connection limited to MAC: $NICDEVICE"
+ for device in /sys/class/net/*; do
+ dev=${device##*/} ;
+ addr="$(cat $device/address)"
+ if [ -n "$(echo $NICDEVICE | grep -iF "$addr")" ]
+ then
+ NETDEV="$NETDEV $dev"
+ break
+ fi
+ done
+ # Remove the leading space
+ NETDEV="$(echo $NETDEV)"
+ if [ -z "$NETDEV" ]
+ then
+ echo "no NICs found to check for MAC passed"
+ else
+ echo "NIC interface connection made to MAC: $NETDEV"
+ echo "DEVICE=$NETDEV" >> /conf/param.conf
+ fi
+ return
+ ;;
esac
done
else
Reply to: