6

I know that something like eth0, eth1, ... has been replaced for long time by more predictable names. However, I don't understand what rule is applied if comes to Ethernet devices. I have multiple virtual servers (libvirt) with Debian 11 and 12 and sometimes the virtual servers use ensX and sometimes enpXsY.

Can I force a server to use ensX instead of enpXsY?

1

1 Answer 1

15

If the firmware of the system provides a PCI Express hotplug slot number for the NIC, you'll see a ensX name. If the firmware claims the NIC is integrated to the system board, you'll see a enoX name. Otherwise, for any PCI/PCI-X/PCIExpress NIC, a enpXsY style name will be used.

Note that in enpXsY, the numbers X and Y will directly reflect the NIC's PCI Bus ID (enpXsYfor X:Y.0, enpXsYfZfor X:Y.Z when Z != 0), although the NIC names use decimal numbers while PCI bus IDs are hexadecimal. For example, enp0s29f6 is PCI ID 0:1d.6.

With udevadm info -q all -p /sys/class/net/<interface name> | grep ID_NET_NAME_, you can view all the auto-detected name candidates for a network interface.

If the system firmware does not provide a physical slot numbering, then the ensX names will simply not be available. You could create completely custom NIC names using the same naming format, but you should not do that without a very good reason.

In modern Debian, you can assign a custom name to a network interface using a /etc/systemd/network/*.link file. Such a file needs to have two sections: a [Match] section containing the rules to determine which NIC this file should apply to (see man systemd.link for details), and a [Link] section overriding the standard naming policy and specifying a custom name.

For example, I have a 4G "portable WiFi access point" which apparently changes its MAC address every time it's powered on, maybe to provide some privacy. To stop it from creating a new network interface every time it was connected by USB (using the rndis_host driver... sigh) I created a *.link file to give it a persistent name using the device's USB-readable serial number, like this

[Match]
Driver=rndis_host
Property=ID_SERIAL_SHORT=<serial number here>

[Link]
Description=A very private 4G AP.
NamePolicy=
Name=myAP

When using the Name= line to specify a custom NIC name, you must also set NamePolicy= to an empty string to override the system standard NamePolicy which would otherwise produce an auto-generated name.

3
  • If the system has multiple PCI domains, the domain number is inserted into the interface name as well, prefixed with capital P. Commented Jul 1 at 7:39
  • Two comments: 1) You mentioned this in your answer, but it bears pointing out: the eno and ens indices are provided by the motherboard / system / firmware / BIOS / UEFI / whatever to Linux. If they are missing or confusing, that's not Linux's fault. (We have some servers where the older generation reports the two onboard NICs as eno1 and eno2, which nicely matches the labeling on the rear of the server, whereas the newer generation reports them as eno8303 and eno8403, but still labels them as "1" and "2" on the server itself.) And 2) The default naming has been tweaked about a … Commented Jul 1 at 10:15
  • … dozen times in systemd: freedesktop.org/software/systemd/man/latest/… Commented Jul 1 at 10:17

You must log in to answer this question.

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