How to replace a USB Wifi dongle while keeping the interface name?

Hello,

I currently have a working USB Wifi Dongle configured with NetworkManager as an access point, showing up in ip addr as an interface of the wlp1s12f1u1 form
That interface name is used in various places in my system, in particular inside shorewall rules to make sure devices connecting to this AP can only see the resources they are supposed to see.

While this works, the dongle is starting to show its age with lack of recent protocol support and limited range.
A replacement dongle has arrived, but before I use it, I was wondering if it’s possible to connect it in lieu of the existing one and keep the interface name.

My list of steps would be this:

  1. Turn off the computer
  2. Unplug the existing dongle
  3. Plug the new dongle on the same USB port
  4. Restart the computer

Would this guarantee that the interface name is the same after reboot ?
Or should I add another step above ?

“Guarantee” is putting it too strongly, because systemd does occasionally glitch when it comes to naming devices and peripherals. This is why you can create a more persistent alias for the device by using its hardware-specific footprint — e.g. a MAC address. (Caveat: I’ve never done that, but I know it’s possible.)

All things considered, I think you’ll probably be fine doing it the way you intend to, but why not see for yourself? Just try it. :wink:

Here’s how I solved it:

cat /etc/systemd/network/10-fixed-nic-name.link
[Match]
MACAddress=00:10:18:3d:c8:84

[Link]
Name=lan0
3 Likes

If you connect the new adapter to the same port - it would be the same interface name.

This is what systemd calls predictable names because it refers to the internal address of the port which will never change.

3 Likes

Thanks to all of you, it indeed received the same interface name.

However, the Network Manager connection did not come back up properly at boot time. I then used this command

nmcli d connect wlp1s12f1u1

which gave me this error:

**A 'wireless' setting is required if no AP path was given**

Looking around, it seemed related to “client” mode not access point as I was aiming for.
After a bit of fiddling, I found that I could also run this command:

sudo nmcli con up ConnectioName ifname wlp1s12f1u1

With the hopes of “forcing” the connection to use the new device even if it had the same name. And this gave me the real reason:

Erreur : périphérique « wlp1s12f1u1 » incompatible avec la connexion « ConnectioName » : Les MAC de périphérique et de la connexion ne correspondaient pas..

Which roughly translates as “device is not compatible with connexion, MAC addresses don’t match”

And sure enough, a look at the device properties gave me this:

802-11-wireless.mac-address: 08:EA:35:FF:FF:FF

which is the MAC address of the previous dongle. Using nmcli to replace it with the new MAC was easy enough, and after another reboot, I’m back to normal.

So if I was to add a step, it would be to check Network Manager’s configuration to make sure MAC addresses will match up.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.