No, this ain't a duplicate of Why doesn't my Wi-Fi adapter show up as wlan0 in 16.04?, as this explains how to restore
eth0 naming, but not how to individually name a specific interface.
I don't want to assign based on MAC match. All I need is to assign name based on the USB path.
When I plug in an USB network adapter, on Ubuntu 17.04 it gets assigned a network interface name based on its MAC, such as
encx000000000000. Now I would like to rename it to something more telling, based on its ID_PATH=
pci-000:02:03.0-usb-0:1:1.0. In particular, I don't want to match based on MAC address.
The rationale is that after interface replacement all would break down, but if someone simply replaces network interface hardware so that the new hardware is in the same place as the old one, the system will tuck on without needing IT and reconfiguration support.
So I created a file
[Match] Path=pci-000:02:03.0-usb-0:1:1.0 [Link] Name=island0
Unfortunately, the name is never assigned. Using
udevadm info I can see that there is
ID_NET_NAME=island0 set, but it does not apply. Trying
NamePolicy=name under the
[Link] section doesn't help either.
I'm lost! How can I assign my name in the .link file to my USB network adapter? Is this possible at all without resorting to some udev rule? Why then having .link files at all when they don't seem to work in my case? Where did I make an error?
So I finally figured out myself what really is happening.
Alas, the problem I'm seeing that renaming USB-based network interfaces doesn't work is actually caused by the udev rule
/lib/udev/rules.d/73-usb-net-by-mac.ruleson Ubuntu/Debian (and thus also Raspbian). The culprit in it is here:
Notice how this specific rule checks for
/udev/rules.d/80-net-setup-link.rulesto be present; if it's not, then
NAMEwill be set to a MAC48-based name, and the later default install rule
/udev/rules.d/80-net-setup-link.ruleswill never get a chance to assign
NAME. Now that's sad. Again.
In order to enable the ability to assign user-defined names to USB network interfaces, we need to have
/udev/rules.d/80-net-setup-link.rules, as this is the rule set
73-usb-net-by-mac.ruleschecks against before assigning
This means that simply linking from
/lib/udev/rules.d/80-net-setup-link.rulesis needed in order to avoid that user-assigned network interface names get ignored any longer.
Please note that a side-effect of the way
73-usb-net-by-mac.rulesis set up, this causes all USB-based network interfaces to assume "old" naming
eth0, et cetera, unless explicitly named in a
I don't know why the rules have been written as they are, as it would be fine to have MAC-based naming for all USB network adapters not explicitly named. On a second thought ... no, using MAC48-based names does not make any sense, unless you happen to label all your USB network dongles and constantly swap them around; but maybe the MAC-based names are used with docking stations, where it actually would make sense...?