Network interface names
Rémy Dernat
remy.d1 at gmail.com
Thu Nov 22 12:18:52 CET 2018
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).
Best regards,
Rémy.
Le jeu. 22 nov. 2018 à 09:54, Rémy Dernat <remy.d1 at gmail.com> a écrit :
> Hi,
>
> I am facing the same issue. However, I would like to adopt the new naming
> style, and so, retrieving the interface name dynamically.
>
> The Debian script previously cited seems to do the job at the FAI nfsroot
> step, during installation. However, when it reboots, it looses the ability
> to get this new name.
>
> What I did :
> - copying this debian script (
> https://github.com/faiproject/fai-config/blob/master/scripts/DEBIAN/30-interface
> ) into a BIONIC64 (ubuntu 18.04) class (script/BIONIC64/),
> - In the files/ subdirectory in fai-config directory, I created 2 files :
> - etc/cron.d/dhclient/BIONIC64 (to launch dhclient at reboot),
> - etc/netplan/01-netcfg.yaml/BIONIC64.
>
> I tried to put $NIC1 in those files thinking it would be replaced by the
> right interface name, but it is not.
>
> So, I think that FAI variable cannot be used in the files/ subdirectory
> because it is not avalaible anymore at this step (after the install).
>
> $NIC1 is used in this script
> https://github.com/faiproject/fai/blob/master/lib/get-boot-info
>
> Any idea on how to achieve this according to the new naming convention ?
>
> Kind regards,
> Rémy.
>
> Le lun. 15 oct. 2018 à 09:37, Steffen Grunewald <
> steffen.grunewald at aei.mpg.de> a écrit :
>
>> Hi,
>>
>> thanks for the responses which may turn out to be helpful in some way (if
>> it's
>> already too late to get hold of the old-style if names) - during a
>> half-hearted
>> test, the grub cmdline trick did not work for me.
>>
>> What still makes me curious is
>>
>> > > What I still haven't found is which magic FAI uses to avoid the
>> renaming
>> > > to "predictable network interface names" (a term that's completely
>> misleading
>> > > to me as I'm unable to predict the network names if I'm given a
>> brand-new
>> > > machine). Thomas, can you shed some light on this?
>>
>> If I run FAI sysinfo, I see eth0, ..., wlan0, etc., and dmesg.log doesn't
>> contain any "renamed to" strings, so this renaming must have been avoided
>> somehow, and it's the "how" I am still looking for. (I.e., was makes the
>> NFSROOT special in this respect as it uses the default kernel?)
>>
>> > > My plan is to read the (old-style) interface names assigned by FAI,
>> then
>> > > create a $target/etc/udev/rules.d/70-persistent-net.rules file from
>> that
>> > > information. Is there a hidden trap? When is it best to write that
>> file?
>>
>> As long as the un-renamed if names are available witin FAI, it's simple to
>> create that rules file. The devil may be in the detail when it's required
>> to exist (I suspect there's some initrd magic?)...
>>
>> Thanks again,
>> Steffen
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-koeln.de/pipermail/linux-fai/attachments/20181122/516f4c2a/attachment.html>
More information about the linux-fai
mailing list