UDEV rules for persistent name USB WLAN do not work

Good day to all!
The essence of the question is as follows. I have two USB WI-FI network cards. By default, UDEV assigns them the names wlan0 and wlan1, respectively. If I change the USB port for any of these network cards, then after the reboot, the names of the network interfaces may also change. I need each network card to always have the same network interface name, regardless of which USB port it is connected to.
I tried using the MAC address to identify network interfaces:

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="aa:bb:cc:dd:ee:ff", NAME="wifi2g"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ee:dd:cc:bb:aa", NAME="wifi5g"

Then I tried using “idVendor” and “idProduct”:

SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="vid1", ATTRS{idProduct}=="pid1", NAME="wifi2g"
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="vid2", ATTRS{idProduct}=="pid2", NAME="wifi5g"

In both cases, the UDEV rule only works for one network card, namely “wifi5g”. And the name of the second network card always remains “wlan1”, so that I do not undertake.
Why is this happening? What else can be done?

In addition
I also checked the output of dmesg|grep wlan.
And that’s what I saw:

[ 16.771747] RTW: rtw_ndev_init(wlan0) if1 mac_addr=1c:bf:ce:4b:90:05
[ 16.799590] rtl88x2bu 1-3.1:1.0 wifi5g: renamed from wlan0
[ 16.980804] rt2800usb 1-2:1.0 wifi2g: renamed from wlan0
[ 292.403577] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready

Why does the system initially try to bind both rtl88x2bu and rt2800usb drivers to the wlan0 interface???

Although the output of the “iw dev” command shows:

phy#1
Interface wlan1

It confused me in general.

is it possible that you did the udev rules in only one file ? From what i know/heard it should be always a separate and individual file for each device.

1 Like

Hi, Olli
On the WIKI pages for Manjaro Linux, I did not find any instructions on this. But on the WIKI pages for Arch Linux, there is a subsection “Tips and tricks” in the “Network configuration” section. This section discusses the topic “Change interface name”. It states that the settings for all interfaces together should be done in the same file /etc/udev/rules.d/10-network.rules.

But, thank you for the advice. I’ll try your version and tell you what the result was.

I checked your option.
I have placed UDEV rules for different interfaces in different files.
/etc/udev/rules.d/10-wifi2g.rules
and
/etc/udev/rules.d/20-wifi5g.rules
Unfortunately, it didn’t help. I did a system reboot. No changes.