16

Recent version of Ubuntu and Debian (stretch) bring a new network interface naming scheme.

Now, when updating from a system that's using old style names like "eth0", I'd like to know prior to booting what the new name will be.

How can I do this? Is there a magic invocation of "systemd" I can use to edit /etc/network/interface befor booting (and subsequently losing network connectivity)?

1

5 Answers 5

7

There's two different schemes available: biosdevname vs predictable network interface name.

biosdevname

Biosdevname seems to be the default in ubuntu. It is activated by installing the biosdevname package.

The biosdevname of an interface can be found with:

biosdevname -i eth0

Predictable network interface names

I believe this is the default in Debian stretch, but needs to be explicitly enabled on upgrade from previous releases.

The predictable name for eth0 can be found with:

udevadm test-builtin net_id /sys/class/net/eth0 | grep '^ID_NET_NAME_'
1
  • Though the actual answer on how to predict "prior to booting what the new name will be" (according to the link provided by @Neil) is the new name will be the same as the old name, because there are still udev rules which configure the old names in /etc/udev/rules.d/70-persistent-net.rules. The link will provide a migration guide, if you want to switch to new naming scheme.
    – Tuomas
    Aug 12, 2018 at 14:04
2

The new scheme is apparently called "predictable network interface names" but I'm not finding a lot of documentation on how to actually predict the name. Everything I've found about it basically points to this source code comment (which itself points back to the first link). From the comment, it's not clear at all how to know which addressing scheme udev is going to use for the network device name.

Per the first link, you can disable it and use the traditional names by adding net.ifnames=0 on the kernel command line in Grub. According to this comment it might be necessary if you plan on creating a VLAN tagged interface, since the added extension will make the interface name too long.

Otherwise, it might be better to re-ask the question to explain what you're trying to do with the name (eg configure the interface through ansible or something similar)

2

I'm not sure if this is still the case with updated versions, but on my old systems I was able to create an empty file at /etc/udev/rules.d/80-net-name-slot.rules and it would disable the "predictable" naming feature. You can also create your own rule and name the interfaces by yourself based on mac address or PCI/USB connections.

0

This documentation might help a little bit. See the section under "What precisely has changed in v197?". Yes, I realize this is of somewhat limited value, but it might give you an avenue for further research.

0

We're using the following "one-liner" in our company to map existing interfaces to their respective predictable name:

echo; [ -e /etc/systemd/network/99-default.link ] && echo '!!! Predictable Network Interface Names are disabled - /etc/systemd/network/99-default.link exists! !!!' && ls -l /etc/systemd/network/99-default.link && echo; echo; [ -e /etc/udev/rules.d/80-net-setup-link.rules  ] && echo '!!! Predictable Network Interface Names are disabled - /etc/udev/rules.d/80-net-setup-link.rules  exists! !!!' && ls -l /etc/udev/rules.d/80-net-setup-link.rules && echo; for i in /sys/class/net/*; do udevadm info -q property "$i" | perl -Mwarnings -Mstrict -e 'my $res = {}; while(<>) { chomp; my @f = split /=/, $_, 2; $res->{$f[0]} = $f[1]; }; printf "%s: %s\n", $res->{DEVPATH}, $res->{ID_NET_NAME_FROM_DATABASE} // $res->{ID_NET_NAME_ONBOARD} // $res->{ID_NET_NAME_SLOT} // $res->{ID_NET_NAME_PATH} // $res->{ID_NET_NAME_MAC} // "???";'; done

It implements the ordering described on https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ can be quickly copy-pasted via SSH.

Example output from my machine:

/devices/virtual/net/docker0: ???
/devices/pci0000:00/0000:00:01.2/0000:02:00.2/0000:03:09.0/0000:2a:00.0/net/enp42s0: enp42s0
/devices/virtual/net/lo: ???
/devices/virtual/net/tun0: ???
/devices/virtual/net/veth732bf87: ???
/devices/pci0000:00/0000:00:01.2/0000:02:00.2/0000:03:08.0/0000:29:00.0/net/wlo1: wlo1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .