USB Ethernet Interface Changes Names Depending on What Port It's On--Breaks Configuration in Network Manager?

This is related to Sabrent USB 2.5G Ethernet Adapter: Realtek 8152 Chipset Drivers from AUR?. I’ve split it off from there because I already set that thread to sprawling with a digression on MTU and jumbo frames.

tl;dr: The network interface name of a USB ethernet adapter changes when it’s switched to a different ethernet port and I need a way to make it not do that.

In the course of investigating adding a powered USB 3.0 hub to the setup to get around the issue of not being able to put an external USB SSD and the 2.5GbE adapter on the Pi’s USB bus, I lost network connectivity to the switch from the 2.5Gb ethernet port.

I swapped things around a bit so that I was just using the Pi’s built-in ethernet again, and got back into an SSH terminal and then took a look at the USB adapter to see what it was doing.

The network interface name (enp1XXXXX) had changed. Apparently, it changes based on what port it’s plugged into. As soon as I set the proper name of the adapter in nmtui (the Network Manager text-based console UI).

A couple of questions:

  1. Why does this happen? Is it just from changing the plug I’m using?
  2. Can I actually make it not do this? Sometimes I need to unplug and move things around, and locking myself out of a machine because I can’t remember which port I used to hook it up the last time ends up with me hard rebooting a running Pi at least once, which is no fun.

It would be nice to give the adapter a permanent name based on its MAC address. eth1 or something.

Thanks!

Hi @johntdavis84,

  1. I happens because every port is a different “PCI” slot to the computer. It changed from the ethX naming scheme I was used to. I first came across it on an Ubuntu server. AFAIK there’ no way to change it.
  2. That said, I’m guessing it would be possible to set up a dbus listener to create a symlink to the device on plugin and removing the symlink on plugging the device out. Or an alias. Or something like that.

Hope this helps!

This is called predictable interface names which is part of systemd.

Due to the nature of systemd and that systemd uses udev - devices are loaded in random order and with a naming that stems from the bus:port combination.

You can create a udev rule which sets the name of your device based on e.g. the vendorid xxxx:yyyy or the serial number. The following article do not explicitly mention an usb network device but it should be fairly easy to apply the logic to your use case.

https://wiki.archlinux.org/index.php/Udev

2 Likes

Now I know as well, thank you very much! I knew it was a new kind of thing that I discovered in Ubuntu originally. And I knew it helps identify a physical device better, since it’s linked yo which PCI (PCIe) slot it’s connected (inserted) to. But I didn’t know about the udev rule, that you mentioned, so thank you very much!