<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Steffen,<div><br></div><div>That is weird; this should work even for pure debian.<br><br>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) :</div><div><br></div><div><div>```</div><div><div>#! /bin/bash</div><div><br></div><div>iface=`ip -o -f inet addr show |awk '$2 !~ "lo|docker" {print $2;exit;}'`</div><div>mac=`ip -o -f link addr |awk -v iface=$iface '{ if ( $2 == iface":" ) {print;} }' |cut -d"/" -f2|awk '{print $2}'`</div><div>fields="ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT ID_NET_NAME_PATH"</div><div>for field in $fields; do</div><div> name=$(udevadm info /sys/class/net/$iface | sed -rn "s/^E: $field=(.+)/\1/p")</div><div> if [[ $name ]]; then</div><div> newnicname=$name</div><div><span style="white-space:pre-wrap"> </span>break</div><div> fi</div><div>done</div><div><br></div><div><br></div><div>fcopy /etc/netplan/01-netcfg.yaml</div><div>fcopy /etc/cron.d/dhclient</div><div><br></div><div>sed -ri "s|inet_to_replace|$newnicname|" $target/etc/netplan/01-netcfg.yaml</div><div>sed -ri "s|inet_to_replace|$newnicname|" $target/etc/cron.d/dhclient</div><div>sed -ri "s|inet_to_replace|$newnicname|" $target/etc/network/interfaces</div><div>sed -ri "s|mac_to_replace|$mac|" $target/etc/netplan/01-netcfg.yaml</div></div><div>```</div></div><div><br>What would be interesting would be to get your logs, particularly your "variables.log" (for example, to check $NIC1) and "error.log". </div><div>Moreover, if you can also supply your network configuration files (/etc/network/interfaces and so on...), it would be useful.</div><div><br></div><div>Best regards,</div><div>Rémy.<br><br><br><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">Le jeu. 22 nov. 2018 à 17:22, Steffen Grunewald <<a href="mailto:steffen.grunewald@aei.mpg.de">steffen.grunewald@aei.mpg.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, 2018-11-22 at 12:18:52 +0100, Rémy Dernat wrote:<br>
> Ok; replying to myself. I found the solution.<br>
> <br>
> I just created a script for my BIONIC64 class (using the debian script) :<br>
> <br>
> ```<br>
> #! /bin/bash<br>
> <br>
> iface=`ip -o -f inet addr show |awk '$2 !~ "lo|docker" {print $2;exit;}'`<br>
> mac=`ip -o -f link addr |awk -v iface=$iface '{ if ( $2 == iface":" )<br>
> {print;} }' |cut -d"/" -f2|awk '{print $2}'`<br>
> fields="ID_NET_NAME_FROM_DATABASE ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT<br>
> ID_NET_NAME_PATH"<br>
> for field in $fields; do<br>
> name=$(udevadm info /sys/class/net/$NIC1 | sed -rn "s/^E:<br>
> $field=(.+)/\1/p")<br>
> if [[ $name ]]; then<br>
> newnicname=$name<br>
> break<br>
> fi<br>
> done<br>
> <br>
> <br>
> fcopy /etc/netplan/01-netcfg.yaml<br>
> fcopy /etc/cron.d/dhclient<br>
> <br>
> sed -ri "s|inet_to_replace|$newnicname|" $target/etc/netplan/01-netcfg.yaml<br>
> sed -ri "s|inet_to_replace|$newnicname|" $target/etc/cron.d/dhclient<br>
> sed -ri "s|inet_to_replace|$newnicname|" $target/etc/network/interfaces<br>
> sed -ri "s|mac_to_replace|$mac|" $target/etc/netplan/01-netcfg.yaml<br>
> ```<br>
> <br>
> With `{mac,inet}_to_replace` in those files (which is replaced with my sed).<br>
<br>
Hi Remy,<br>
<br>
this doesn't work for pure Debian (which hasn't been converted to use netplan<br>
AFAICT), but I can imagine to use udev rules to assign any (old or new style)<br>
interface names to the devices.<br>
<br>
I'm running a class script that collects all available interface names (as<br>
the FAI NFSROOT creates them) and MACs, and builds a persistent-net.rules file.<br>
<br>
For now, I'm sticking with old-style ones, but this script could be adapted<br>
to use udevadm info to retrieve the "new-style name" from /sys/class/net/eth*<br>
should this become necessary.<br>
<br>
Thanks for sharing your insight,<br>
Steffen<br>
</blockquote></div>