On Wed, 2019-07-03 at 11:23:24 +0200, Thomas Lange wrote:
> >>>>> On Tue, 2 Jul 2019 14:28:30 +0900, Chetan Neve <[email protected]> said:
>
> > Hi Thomas, is it possible to make ethernet device name static through
> FAI?
> > eg. eth0
> The trick is to use the options "net.ifnames=0 biosdevname=0"
> on the kernel cmdline. FAI itself
> uses the the old names during installation, but then in the script
> DEBIAN/30-interfaces the subroutine newnicnames() maps the old names
> to the new ones. The new names are then used in /etc/network/interfaces.
>
> You have to change the logic in this script.
If you don't want to change that globally, you can also create an udev rules
file
that has to be installed later.
I'm using the following *class* script (useful because it's also run in sysinfo
mode) to dump the interface mapping. It has to be a *.sh one:
--->
#!/bin/bash
# extract NIC names and MACs
getifs() {
ip addr \
| grep '^\S' \
| cut -d: -f2 \
| tr -d ' ' \
| grep -v '^lo$' \
| grep -v '^usb' \
| sort
}
getmac() {
ip addr show $1 \
| grep link/ether \
| awk '{print $2}' \
| tr '[A-F]' '[a-f]'
}
interfaces=$(getifs)
# should be identical to $netdevices_all
echo Interfaces ${interfaces}
for interface in ${interfaces}
do
macaddr=$(getmac ${interface})
echo MAC ${interface} ${macaddr}
# keep for future reference
echo mac_${interface}=${macaddr} >> $LOGDIR/additional.var
# avoid quoting quotes
cat >> $LOGDIR/persistent-net.rules << EOF
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="${macaddr}",
NAME="${interface}"
EOF
done
<---
You may also copy the file from the sysinfo log tree into files/etc/udev/rules.d
for a later installation.
HTH, Steffen