Skip to main content
Topic: Network interface names (Read 1347 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Network interface names

Since some recent update my network interface names have reverted to their old names like wlan0 and eth0.

Is there a way to go back to consistent interface naming that became standard a couple of years ago?

Re: Network interface names

Reply #1
The kernel assigns the wlan0 / 1 names but they seem to be renamed by udev to consistent names. So I guess this xudev eudev doesn't have that feature enabled?
It seems to work downgrading to original eudev for now, which is a quick temporary way to get the old names back:
Code: [Select]
/var/cache/pacman/pkg$ sudo pacman -U libeudev-3.2.10-3-x86_64.pkg.tar.zst eudev-3.2.10-3-x86_64.pkg.tar.zst lib32-eudev-3.2.10-1-x86_64.pkg.tar.zst
Although it hung for quite a while at one point and gave an error:
Code: [Select]
(2/3) Reloading device manager configuration...
error: command failed to execute correctly
but after it eventually completed (and do let it complete or it might result in an unbootable system!) it works OK after rebooting. I was also looking at the package build dates:
Build Date      : Mon 10 May 2021 00:19:56 BST
 and there have been commits to eudev virtually right up until the deprecation announcement, and Gentoo are leaving it until 2022 before removing it, so it would be possible to build your own newer version and run it for a while yet if required probably.
(There might be better answers to your question yet, but as there haven't been so far there is one  ;D )

Re: Network interface names

Reply #2
I find the "consistent" interface names confusing and unnecessarily complicated compared to the traditional names. Just another example of corpo overengineering. How often is one adding multiple network devices on the fly anyway?

As for the "standard"... systemd has "become the standard" years ago, doesn't mean everyone has to use it.

Re: Network interface names

Reply #3
It's quite simple it turns out, xudev-eudev is missing a udev rule that Gentoo eudev had, probably because this is handled elsewhere in systemd and adding this short file returns to the previous behaviour, which can also be disabled as before by adding net.ifnames=0 to the kernel commandline:

Code: [Select]
$ cat /usr/lib/udev/rules.d/80-net-name-slot.rules 
# do not edit this file, it will be overwritten on update

ACTION!="add", GOTO="net_name_slot_end"
SUBSYSTEM!="net", GOTO="net_name_slot_end"
NAME!="", GOTO="net_name_slot_end"

IMPORT{cmdline}="net.ifnames"
ENV{net.ifnames}=="0", GOTO="net_name_slot_end"

NAME=="", ENV{ID_NET_NAME_ONBOARD}!="", NAME="$env{ID_NET_NAME_ONBOARD}"
NAME=="", ENV{ID_NET_NAME_SLOT}!="", NAME="$env{ID_NET_NAME_SLOT}"
NAME=="", ENV{ID_NET_NAME_PATH}!="", NAME="$env{ID_NET_NAME_PATH}"

LABEL="net_name_slot_end"

Putting this file in /etc/udev/rules.d works too.

Re: Network interface names

Reply #4
net.ifnames=0 is appended to grub command line by default in all our profiles. We find eth0 way more legible than en0s2p3. Mission-critical installations with lots of NICs should have admins capable of reverting to persistent naming.

Re: Network interface names

Reply #5
Without the above udev rule to read it, net.ifnames is meaningless I think, I tried net.ifnames=1 first. I didn't like the new names at first but have got used to them now. On some desktops with lots of USB ports a wireless usb adapter name for example can get too long though. While looking into this, I read somewhere that writing your own custom udev rules to identify things by MAC address then name them whatever you want is the best way to get really consistent names, even if something is plugged into a different port.

Re: Network interface names

Reply #6
The net.ifnames=0 is a kernel parameter that disables the predictable interface renaming behaviour. If some userspace helper like udev ignores or overrides that, then it's wrong and dangerous.

Re: Network interface names

Reply #7
Quickly agging the linux source code I don't see anything checking net.ifnames for 0 or 1 or anything, it's barely mentioned except in a selftest:
Code: [Select]
/linux$ ag ifnames
net/core/rtnetlink.c
1634:static int rtnl_fill_alt_ifnames(struct sk_buff *skb,
1658: ret = rtnl_fill_alt_ifnames(skb, dev);

tools/testing/selftests/bpf/test_offload.py
372:        ifnames = self.get_ifnames()
379:            self.nsims.append(NetdevSim(self, port_index, ifnames[port_index]))
381:    def get_ifnames(self):
382:        ifnames = []
385:            ifnames.append(ifname)
386:        ifnames.sort()
387:        return ifnames
395:                ifnames = self.get_ifnames()
397:                ifnames = []
398:            if len(ifnames) == port_count:
I think the whole net.ifnames kernel parameter thing could be a systemd construct which eudev emulated by that udev rule, it doesn't seem to be in the kernel source. Perhaps looking in the systemd source code would reveal more of how it works, idk as I don't happen to have a copy of that lying about  on my hdd ;D
(To be clear: I didn't write that udev rule myself, it's copy pasted from eudev, and xudev - new systemd eudev does not have it, but possibly should if it wished to maintain old eudev behaviour but I thought most people liked the wlan / eth so possibly it won't be, although that means there is no way to get the new wlp / enp names unless you add the udev rule yourself.)