Systemd – Why Is My Link File Being Ignored?

debiansystemdudev

I want to enable persistent network names in Debian Stretch, and the most robust way appears to be using the ID_NET_NAME_PATH property.

However, my .link file is being ignored and udev appears to be using its own rules to name interfaces.

I made a copy of /lib/systemd/network/99-default.link and placed it in /etc/systemd/network, then changed NamePolicy to:
NamePolicy=path

An example interface is ens2, which appears to be been named with the "slot" policy instead of path. Running udevadm info /sys/class/net/ens2 gives:

P: /devices/pci0000:80/0000:80:02.0/0000:83:00.0/net/ens2
E: DEVPATH=/devices/pci0000:80/0000:80:02.0/0000:83:00.0/net/ens2
E: ID_BUS=pci
E: ID_MODEL_FROM_DATABASE=MT27500 Family [ConnectX-3]
E: ID_MODEL_ID=0x1003
E: ID_NET_DRIVER=mlx4_en
E: ID_NET_LINK_FILE=/etc/systemd/network/99-default.link
E: ID_NET_NAME_PATH=enp131s0
E: ID_NET_NAME_SLOT=ens2
E: ID_PATH=pci-0000:83:00.0
E: ID_PATH_TAG=pci-0000_83_00_0
E: ID_PCI_CLASS_FROM_DATABASE=Network controller
E: ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller
E: ID_VENDOR_FROM_DATABASE=Mellanox Technologies
E: ID_VENDOR_ID=0x15b3
E: IFINDEX=8
E: INTERFACE=ens2
E: SUBSYSTEM=net
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/ens2
E: TAGS=:systemd:
E: USEC_INITIALIZED=15903053

My question is, why is the interface being named ens2 and not enp131s0?

Best Answer

You have to update-initramfs -u for these changes to take effect. This copies the /etc/systemd/network/99-default.link file you created into the initramfs to be around at early system boot when udev needs it.

Related Question