Martin-Éric Racine: Migrating to Predictable Network Interface Names
A couple of years ago, I moved into a new flat that comes with RJ45 sockets wired for 10 Gigabit (but currently offering 1 Gigabit) Ethernet.This also meant changing the settings on my router box for my new ISP.I took this opportunity to review my router's other settings too. I'll be blogging about these over the next few posts.
Migrating to Predictable Network Interface Names
Ever since Linus decided to flip the network interface enumeration order in the Linux kernel, I had been relying on udev's persistent network interface rules to maintain some semblance of consistency in the NIC naming scheme of my hosts. It has never been a totally satisfactory method, since it required manually editing the file to list the MAC addresses of all Ethernet cards and WiFi dongles likely to appear on that host to consistently use an easy-to-remember name that I could adopt for ifupdown configuration files.
Enter predictable interface names. What started as a Linux kernel module project at Dell was eventually re-implemented in systemd. However, clear documentation on the naming scheme had been difficult to find and udev's persistent network interface rules gave me what I needed, so I postponed the transition for years. Relocating to a new flat and rethinking my home network to match gave me an opportunity to revisit the topic.
The naming scheme is surprisingly simple and logical, once proper explanations have been found. The short version:
- Ethernet interfaces are called en i.e. Ether Net.
- Wireless interfaces are called wl i.e. Wire Less. (yes, the official documentation call this Wireless Local but, in everyday usage, remembering Wire Less is simpler)
- enp9s0: Ethernet interface at PCI bus 9 slot 0.
- wlp12s0: Wireless interface at PCI bus 12 slot 0.
#!/bin/sh lspci grep -i -e ethernet -e network sudo dmesg grep -i renamed for n in $(ls -X /sys/class/net/ grep -v lo); do echo $n: && udevadm test-builtin net_id /sys/class/net/$n 2>/dev/null grep NAME; sudo rgrep $n /etc sudo find /etc -name '*$n*' doneThis combined ideas found on the Debian wiki with a few of my own. Running the script before and after the migration ensured that I hadn't missed any configuration file. Once I was satisfied with that, I commented out the old udev persistent network interface rules, ran
dpkg-reconfigure
on all my Linux kernel images to purge the rules from the initrd
images, and called it a day.
... well, not quite. It turns out that with bridge-utils, bridge_ports all
no longer works. One must manually list all interfaces to be bridged. Debian bug report filed.
PS: Luca Capello pointed out that Debian 10/Buster's Release Notes include migration instructions.