1

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

SteveM
  • 13
  • 4

1 Answers1

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

Milliways
  • 62,573
  • 32
  • 113
  • 225