0

I have a RPi 4 8GB with the latest Raspberry Pi OS (August 2020) installed. I need to connect to 2 different APs:

  • wlan0: onboard
  • wlan1: USB dongle

Here is the configuration so far:

  • /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=XX

network={
        ssid="AP1"
        psk="XXXXXXXX"
        scan_ssid=1
}
  • /etc/wpa_supplicant/wpa_supplicant-wlan1.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=XX

network={
        ssid="AP2"
        psk="XXXXXXXX"
}
  • /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.178.100/24
static routers=192.168.178.1
static domain_name_servers=192.168.178.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

interface wlan1
static ip_address=192.168.179.2/24
wpa-conf /etc/wpa_supplicant/wpa_supplicant-wlan1.conf

When I boot the RPi, then:

  • the wlan0 becomes wlan1
  • and...the wlan1 becomes wlan0
  • the wlan1 (onboard WiFi interface) connects to AP2
  • the wlan0 (USB dongle) is down

How can I get wlan0 & wlan1 working?

Thanks in advance!

UPDATED: Solution

My feedback regarding the predictable network interface names AND the udev rules:

  • Predictable network interface names: Enabling this option (raspi-config -> 2 Network Options -> N3 Network interface names Enable/Disable predictable network interface names) was not always assigning (after a reboot) the onboard WLAN as wlan0.
  • UDEV rules: Such a rule based on the MAC is a good option, but requires that the MAC defined within the rule has to be changed...if the WLAN USB dongle is replaced. I found a more suitable solution (at least for me) here: https://www.raspberrypi.org/forums/viewtopic.php?t=198946. In this scenario the USB port will be defined for assigning the interface name "wlan1".

Here is the final configuration:

The WLAN USB dongle will be plugged in the upper left USB port of a RPi 4. The /etc/udev/rules.d/72-wlan-geo-dependent.rules is accordingly as follows:

  • /etc/udev/rules.d/72-wlan-geo-dependent.rules
# Raspberry Pi 4 Model B Rev 1.4
#
# +---------+ ----------+
# | USB 2.0 | | USB 3.0 |
# | 1-1.3   | | 1-1.1   | +------+
# +---------+ +---------+ |      |
# | USB 2.0 | | USB 3.0 | | LAN  |
# | 1-1.4   | | 1-1.2   | |      |
# +---------+ +---------+ +------+

ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="sdio", KERNELS=="mmc1:0001:1", NAME="wlan0"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="usb",  KERNELS=="1-1.3",       NAME="wlan1"
  • /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=XX

network={
        ssid="AP1"
        psk="XXXXXXXX"
        scan_ssid=1
}
  • /etc/wpa_supplicant/wpa_supplicant-wlan1.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=XX

network={
        ssid="AP2"
        psk="XXXXXXXX"
}
  • /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.178.100/24
static routers=192.168.178.1
static domain_name_servers=192.168.178.1

interface wlan1
static ip_address=192.168.179.2/24
4
  • Is dmeswpa-conf a real error or just a transcription error on here? Should be wpa-conf ....
    – Dougie
    Aug 29 '20 at 21:38
  • Thanks, It was an editing error from my side. It is wpa-conf ... in the /etc/dhcpcd.conf .
    – SteveM
    Aug 30 '20 at 7:16
  • There is no wpa-conf directive in dhcpcd - you can't just invent things and expect them to work. Have you read the man page?
    – Milliways
    Aug 30 '20 at 10:12
  • Indeed there is no such directive. But I found some descriptions about this setup, where they used to use the wpa-conf in the dhcpcd.conf. I removed these lines from the solution that I posted.
    – SteveM
    Aug 30 '20 at 12:28
0

If I understand your rather vague Question you are asking about the allocation of names to Network Interfaces.

You should use Predictable Network Interface Names which have been used in other distributions for some time.

These are designed for multiple network interfaces to eliminate the enumeration race condition.

There is an option in raspi-config to enable predictable network interface names.

See Predictable Network Interface Names in How to set up networking/WiFi for further detail.

Use different wpa_supplicant files explains how to configure dhcpcd to use different wpa_supplicant.conf files for a specific wireless interface.

You may also want to look at Prevent dhcpcd from configuring a gateway on an interface

3
  • No, I am asking...how I can get it working: wlan0 connect to AP1 and wlan1 connect to AP2. I think that networking setup was "easier" before Buster...like in Jessie by using the /etc/network/interfaces.
    – SteveM
    Aug 30 '20 at 7:22
  • 1
    Your Comment doesn't make anything clearer - NOTE you should edit your Question to add detail. There is NO way you can ensure wlan0/wlan1 are allocated to specific interfaces (although it may be possible with by writing udev rules based on MAC - but this is what Predictable Network Interface Names do.) as these are allocated in the order they are enumerated. The on-board WiFi should win as it is connected by sdio. The later OS are NO DIFFERENT to Wheezy (which was the last to use Debian networking) there has ALWAYS been a race condition.
    – Milliways
    Aug 30 '20 at 7:33
  • Thank you for the feedback regarding the predictable network interface names and udev rules. This was at least a point for me to start investigating it!
    – SteveM
    Aug 30 '20 at 12:30

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .