0

I actually like predictable interface names I just want to know them before rebooting after a Debian dist-upgrade so that I can change the /etc/network/interfaces accordingly. Any idea how to predict them?

3

Note: when you upgrade a Debian system that originally used old-style names, it will keep using old-style names by default: the upgrade process will place a symlink to /dev/null as /etc/systemd/network/99-default.link which will override the new naming policy file /lib/systemd/network/99-default.link. If you choose to use the new style, just rm /etc/systemd/network/99-default.link before rebooting after the upgrade.

If the new version of udev ruleset is already in place (as you indicated: after apt dist-upgrade but before rebooting), then

udevadm info -q all -p /sys/class/net/<current name of interface> |grep ID_NET_NAME

should display all the naming options, in the order of descending priority:

  • ID_NET_NAME_ONBOARD enoN will appear if there is DMI information identifying the network interface as an on-board integrated NIC. By default, this name takes priority over all other options.
  • if the NIC is in a PCIe hot-plug slot, you may see a ID_NET_NAME_SLOT ensN number identifying the corresponding slot number
  • ID_NET_NAME_PATH enpNsM corresponds to PCI device id N:M.0. Unfortunately the device name numbers are in decimal, while PCI device IDs use hexadecimal, so some conversion may be in order.
  • if a NIC has multiple ports that appear as separate PCI functions (PCI id N:M.L), then ID_NET_NAME_PATH will be enpNsMfL instead.
  • there is also the ID_NET_NAME_MAC enx<MAC address in hex> format. This is not used by default, but might be convenient on USB-connected NICs.

If you don't have even run the upgrade yet, then the procedure would be:

  • first, run dmidecode -t10. If it reports any Ethernet interfaces, they will be listed as onboard ones (enoN).
  • if you have NICs in hot-plug capable PCIe slots, your hardware manual will hopefully identify the slot numbering.
  • then, use ethtool -i ethN | grep bus-info to see the PCI bus identifier of a NIC. Convert the bus ID numbers from hex to decimal and you'll know the enp... form of the new names. For example:

    bus-info: 0000:00:19.0

will map to enp0s25, and a dual-port NIC with

bus-info: 0000:01:00.0

and

bus-info: 0000:01:00.1

will map to enp1s0f0 and enp1s0f1.

If you want to tweak the default naming, you can do it with .link files in /etc/systemd/network/ directory: see man systemd.link for details. For example, if you want to use the enx<MAC> style naming for USB network interfaces, you can add file /etc/systemd/network/81-usbnet.link with the following contents:

[Match]
Path=*usb*

[Link]
NamePolicy=database mac

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.