0

I connected a wifi adapter, I have a different connection configuration for each one but when restarting the interfaces change, wlan0 -> internal wifi, wlan1 -> external wifi After reboot: wlan1 -> internal wifi, wlan0 -> external wifi And in every reboot it can changes Is there a way that interfaces are always the same?

4
  • 1
    raspi-config : choose "Advanced Options" then "Network Interface Names" and say yes to predictable network interface names - please note, your USB wifi interface name won't be wlan0 or wlan1 - it will be some long (but predictable, i.e. never changing) name Jan 26 at 0:49
  • note: this will also effect the name of eth0 ... it'll be something like enxb827eb123456 where b827eb123456 is the mac address of the ethernet interface Jan 26 at 1:21
  • Excelent, just what I needed, Thanks
    – Isra
    Jan 26 at 1:39
  • I've added an alternative workaround in the answer below Jan 26 at 2:04
0

You can achieve stable interface names by enabling predictable network names

In raspi-config, select "Advanced Options" then "Network Interface Names" and say "yes" to predictable interface names, and reboot

However, this will result in eth0 being called something like enx010203040506 where 010203040506 is the MAC address for the ethernet port, similarly any USB wifi adapter will be called wlx020304050607 where 020304050607 is the MAC address of the USB wifi adapter

An alternative method to enabling predictable network names in raspi-config is by firstly making sure predictable names are disabled in raspi-config, (this is important as predictable names override manually configured names)

edit: according to this raspberry pi forum question if you

sudo ln -s /lib/udev/rules.d/80-net-setup-link.rules /etc/udev/rules.d/80-net-setup-link.rules

then you can have predictable names enabled AND override the names using the method below - I have not tested this

Now you can create your own interface names by going to /etc/systemd/network folder add the following files (the wlan0 and wlan1 part of the name does NOT matter)

80-wlan0.link

[Match]
MACAddress=xx:xx:xx:xx:xx:xx
[Link]
Name=wlan0

80-wlan1.link

[Match]
MACAddress=yy:yy:yy:yy:yy:yy
[Link]
Name=wlan1

where xx:xx:xx:xx:xx:xx is the MAC address of what you want to be wlan0 and yy:yy:yy:yy:yy:yy is the MAC address of what you want to be wlan1

Note: according to systemd documentation, manually configuring interface names should be enough to override the default behaviour of predictable network names (though, predictable network names are disabled in base install of Raspberry Pi OS, so this isn't really a problem), however in my experience, USB devices still get the predictable network name unless predictable network names are disabled, and any manual network name is ignored - see edit above regarding /lib/udev/rules.d/80-net-setup-link.rules for fixing this issue

Note2: manually assigned network names don't always play nice with vlan network names configured using /etc/network/*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.