SystemD: Understanding  Predictable Network Interface Names

Source 1: http://blog.laimbock.com/2014/11/22/systemd-understanding-predictable-network-interface-names/   by Patrick Laimbock
Source2: https://major.io/2015/08/21/understanding-systemds-predictable-network-device-names/   by  Major Hayden

 

Posted on November 22, 2014 by Patrick Laimbock

Here is an explanation of how SystemD predictable network interface names are determined.

Predictable network interface device names are based on:
– firmware/bios-provided index numbers for on-board devices
– firmware-provided pci-express hotplug slot index number
– physical/geographical location of the hardware
– the interface’s MAC address

Two character prefixes based on the type of interface:

 

en Ethernet
wl WLan
ww WWan

 

 
Type of device names :
b                                    — BCMA bus core number
ccw                               — CCW bus group name
o                                    — on-board device index number
s[f][d]                          — hotplug slot index number
x                                    — MAC address
[P]ps[f][d]                 — PCI geographical location
[P]ps[f][u][..][c][i] — USB port number chain

USB Device
For USB devices, the full chain of port numbers of hubs is composed.
If the name gets longer than the maximum number of 15 characters the name is not exported.
The usual USB configuration == 1 and interface == 0 values are suppressed.

PCI Device
Format of the name: en + [P]ps[f][d]
All multi-function PCI devices will carry the [f] number in the device name including the function 0 device.

When using PCI geography the PCI domain is only prepended when it is not 0.

 
The magic (for naming network interfaces) happens in the source code file named “link-config.c”. It shows that the system searches the udev database in the following order to find out what to call an interface:

  • ID_NET_NAME_FROM_DATABASE
  • ID_NET_NAME_ONBOARD
  • ID_NET_NAME_SLOT
  • ID_NET_NAME_PATH
  • ID_NET_NAME_MAC

Here’s how you can dump the udev database:
# udevadm info e | grep A 11 ^P.*eno1
will select 11 lines after the header for for the ‘eno1’ device, you may need to adjust the number. Or run something like
udevadmin info
udevadm info -p /sys/devices/]

PCI ethernet card with firmware index “1”:
o                                    — on-board device index number
1 ID_NET_NAME_ONBOARD=eno1          (that’s three letters and a number)
2 ID_NET_NAME_ONBOARD_LABEL=Ethernet Port 1

PCI ethernet card in hotplug slot with firmware index number:
1 /sys/devices/pci0000:00/0000:00:1c.3/0000:05:00.0/net/ens1
2 ID_NET_NAME_MAC=enx000000000466
3 ID_NET_NAME_PATH=enp5s0
4 ID_NET_NAME_SLOT=ens1

PCI ethernet multi-function card with 2 ports:
1 /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0/net/enp2s0f0
2 ID_NET_NAME_MAC=enx78e7d1ea46da
3 ID_NET_NAME_PATH=enp2s0f0
4 /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.1/net/enp2s0f1
5 ID_NET_NAME_MAC=enx78e7d1ea46dc
6 ID_NET_NAME_PATH=enp2s0f1

PCI wlan card:
1 /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/net/wlp3s0
2 ID_NET_NAME_MAC=wlx0024d7e31130
3 ID_NET_NAME_PATH=wlp3s0

USB built-in 3G modem:
1 /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.6/net/wwp0s29u1u4i6
2 ID_NET_NAME_MAC=wwx028037ec0200
3 ID_NET_NAME_PATH=wwp0s29u1u4i6

 

How to turn it off

There are 4 ways to turn it off and get back your old trusted network interface names (like ethX etc.):

A. Boot the kernel with net.ifnames=0 (might also need biosdevname=0)

B. Disable the assignment of fixed names so that the unpredictable kernel names are used again by masking udev’s rule file for the default policy:
ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
(since v209: this file was called 80-net-name-slot.rules in release v197 through v208)

C. Use your own manual naming scheme (e.g. “internet0″, “dmz0″ or “lan0″) by creating your own udev rules file and set the NAME property for the devices. Make sure to order it before the default policy file, for example by naming it
/etc/udev/rules.d/70-my-net-names.rules

D. Alter the default policy file for picking a different naming scheme for example for naming all interface names after their MAC address by default:
cp /usr/lib/udev/rules.d/80-net-setup-link.rules /etc/udev/rules.d/80-net-setup-link.rules Then edit the file there and change the lines as necessary.

Advertisements