Network interface names
Rémy Dernat
remy.d1 at gmail.com
Fri Nov 23 10:06:30 CET 2018
Hi Steffen,
That is weird; this should work even for pure debian.
However, reading my message, I saw that some parts of my scripts are
useless. Maybe you can try the following instead (just replacing $NIC1 by
$iface which is not used) :
```
#! /bin/bash
iface=`ip -o -f inet addr show |awk '$2 !~ "lo|docker" {print $2;exit;}'`
mac=`ip -o -f link addr |awk -v iface=$iface '{ if ( $2 == iface":" )
{print;} }' |cut -d"/" -f2|awk '{print $2}'`
fields="ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT
ID_NET_NAME_PATH"
for field in $fields; do
name=$(udevadm info /sys/class/net/$iface | sed -rn "s/^E:
$field=(.+)/\1/p")
if [[ $name ]]; then
newnicname=$name
break
fi
done
fcopy /etc/netplan/01-netcfg.yaml
fcopy /etc/cron.d/dhclient
sed -ri "s|inet_to_replace|$newnicname|" $target/etc/netplan/01-netcfg.yaml
sed -ri "s|inet_to_replace|$newnicname|" $target/etc/cron.d/dhclient
sed -ri "s|inet_to_replace|$newnicname|" $target/etc/network/interfaces
sed -ri "s|mac_to_replace|$mac|" $target/etc/netplan/01-netcfg.yaml
```
What would be interesting would be to get your logs, particularly your
"variables.log" (for example, to check $NIC1) and "error.log".
Moreover, if you can also supply your network configuration files
(/etc/network/interfaces and so on...), it would be useful.
Best regards,
Rémy.
Le jeu. 22 nov. 2018 à 17:22, Steffen Grunewald <
steffen.grunewald at aei.mpg.de> a écrit :
> On Thu, 2018-11-22 at 12:18:52 +0100, Rémy Dernat wrote:
> > Ok; replying to myself. I found the solution.
> >
> > I just created a script for my BIONIC64 class (using the debian script) :
> >
> > ```
> > #! /bin/bash
> >
> > iface=`ip -o -f inet addr show |awk '$2 !~ "lo|docker" {print $2;exit;}'`
> > mac=`ip -o -f link addr |awk -v iface=$iface '{ if ( $2 == iface":" )
> > {print;} }' |cut -d"/" -f2|awk '{print $2}'`
> > fields="ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT
> > ID_NET_NAME_PATH"
> > for field in $fields; do
> > name=$(udevadm info /sys/class/net/$NIC1 | sed -rn "s/^E:
> > $field=(.+)/\1/p")
> > if [[ $name ]]; then
> > newnicname=$name
> > break
> > fi
> > done
> >
> >
> > fcopy /etc/netplan/01-netcfg.yaml
> > fcopy /etc/cron.d/dhclient
> >
> > sed -ri "s|inet_to_replace|$newnicname|"
> $target/etc/netplan/01-netcfg.yaml
> > sed -ri "s|inet_to_replace|$newnicname|" $target/etc/cron.d/dhclient
> > sed -ri "s|inet_to_replace|$newnicname|" $target/etc/network/interfaces
> > sed -ri "s|mac_to_replace|$mac|" $target/etc/netplan/01-netcfg.yaml
> > ```
> >
> > With `{mac,inet}_to_replace` in those files (which is replaced with my
> sed).
>
> Hi Remy,
>
> this doesn't work for pure Debian (which hasn't been converted to use
> netplan
> AFAICT), but I can imagine to use udev rules to assign any (old or new
> style)
> interface names to the devices.
>
> I'm running a class script that collects all available interface names (as
> the FAI NFSROOT creates them) and MACs, and builds a persistent-net.rules
> file.
>
> For now, I'm sticking with old-style ones, but this script could be adapted
> to use udevadm info to retrieve the "new-style name" from
> /sys/class/net/eth*
> should this become necessary.
>
> Thanks for sharing your insight,
> Steffen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-koeln.de/pipermail/linux-fai/attachments/20181123/b10705b8/attachment.html>
More information about the linux-fai
mailing list