Recently I wrote about how Linux network interface names have a length limit , of 15 characters. You can work around this limit by giving network interfaces an 'altname' property, as exposed in (for example) 'ip link' . While you can't work around this at all in Canonical's Netplan , it looks like you can have this for your VLANs in systemd-networkd, since there's
AlternativeName=
in the systemd.link manual page.
Except, if you look at an actual VLAN configuration as materialized by Netplan (or written out by hand), you'll discover a problem. Your VLANs don't normally have .link files, only .netdev and .network files (and even your normal Ethernet links may not have .link files). The
AlternativeName=
setting is only valid in .link files, because networkd is like that.
(The
AlternativeName=
is a '[Link]' section setting and .network files also have a '[Link]' section, but they allow completely different sets of '[Link]' settings. The .netdev file, which is where you define virtual interfaces, doesn't have a '[Link]' section at all, although settings like
AlternativeName=
apply to them just as much as to regular devices. Alternately, .netdev files could support setting altnames for virtual devices in the '[NetDev]' section along side the mandatory 'Name=' setting.)
You can work around this indirectly, because you can create a .link file for a virtual network device and have it work:
[Match] Type=vlan OriginalName=vlan22-mlab [Link] AlternativeNamesPolicy= AlternativeName=vlan22-matterlab
Networkd does the right thing here even though 'vlan22-mlab' doesn't exist when it starts up; when vlan22-mlab comes into existence, it matches the .link file and has the altname stapled on.
Given how awkward this is (and that not everything accepts or sees altnames), I think it's probably not worth bothering with unless you have a very compelling reason to give an altname to a virtual interface. In my case, this is clearly too much work simply to give a VLAN interface its 'proper' name.
Since I tested, I can also say that this works on a Netplan-based Ubuntu server where the underlying VLAN is specified in Netplan. You have to hand write the .link file and stick it in /etc/systemd/network, but after that it cooperates reasonably well with a Netplan VLAN setup .