Network interface names

Markus Köberl markus.koeberl at tugraz.at
Fri Nov 23 15:06:30 CET 2018


On Friday, 23 November 2018 10:06:30 CET Rémy Dernat wrote:
> 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
> >
> 

I am using a modified version of the script https://github.com/faiproject/fai-config/blob/master/scripts/DEBIAN/30-interface to handle the configuration of more than one interface. It did not work always reliable till I found out that sometimes IPADDR is set to "NON-IP".
Never had the time to find the root of the problem but it seams to be related to not booting from the first interface or so.
Maybe you are encountering the same problem?


regards
Markus Köberl
-- 
Markus Koeberl
Graz University of Technology
Signal Processing and Speech Communication Laboratory
E-mail: markus.koeberl at tugraz.at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 30-interface
Type: application/x-shellscript
Size: 2732 bytes
Desc: not available
URL: <http://lists.uni-koeln.de/pipermail/linux-fai/attachments/20181123/f2ccd513/attachment.bin>


More information about the linux-fai mailing list