systemd's Predictable Network Interface Names

Today while setting up a new Proxmox node in my cluster, I ran into a “fun” issue.

This particular node is an old laptop which needs a USB->Ethernet adaptor to connect to the LAN, and due to systemd’s “predictable network interface” naming scheme, the NIC ended up with an interface name like “enx012345678910” (where 012345678910 was the adaptor’s MAC address). This is all fine and good, but I needed to bridge a VLAN on the physical interface to the default virtual bridge Proxmox uses (vmbr0). So I changed /etc/network/interfaces:

...
auto vmbr0
iface vmbr0 inet static
    ...
    bridge_ports enx012345678910.1000
    ...

See the problem? I sure didn’t. After rebooting to apply the settings, I noticed I still wasn’t correctly bridged to the VLAN. After a while, I ended up ifdowning the bridge and ifuping it again and saw the error message:

Error: argument "enx012345678910.1000" is wrong: "name" too long

Ah. So systemd decided to assign me a name that’s so long I can’t use VLANs on it. Great.

The solution is simple but annoying: add a udev rule to force a shorter name. In my case since this machine only has 1 NIC, the following will work just fine:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"