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
dmeswpa-conf
a real error or just a transcription error on here? Should bewpa-conf ...
.wpa-conf
directive indhcpcd
- you can't just invent things and expect them to work. Have you read the man page?