wpa_supplicant for dual WLAN
You create two separate wpa_supplicant.conf
files, one for each interface. Then you specify which conf file goes with which interface when you invoke wpa_supplicant
. You use the -N
option to show that you want to start describing a new interface.
This example comes right out of the wpa_supplicant(8)
man page:
wpa_supplicant \
-c wpa1.conf -i wlan0 -D hostap -N \
-c wpa2.conf -i ath0 -D madwifi
You will need to create two new files in the following directory: /etc/wpa_supplicant/
The new files should be named with the interface name i.e wpa_supplicant-wlan1.conf
You should end up with two files like so:
for interface wlan0:
- file /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
for interface wlan1:
- file /etc/wpa_supplicant/wpa_supplicant-wlan1.conf
content of wpa_supplicant-wlan0.conf file
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="ssid0"
psk="pass0"
}
content of wpa_supplicant-wlan1.conf file
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="ssid1"
psk="pass1"
}
reboot PI and you should have SSID attached to an interface.
@jaanhio Sorry can't comment, thus as an answer. Can somebody please move it to the comments? I think it is quite interessting to know why creating a file wpa_supplicant-wlan1 works.
junaid's answer is correct for debian. On debian (or at least Raspbian Buster) dhcpcd controls wpa_supplicant in /usr/share/dhcpcd/hooks/10-wpa_supplicant
you find
if [ -z "$wpa_supplicant_conf" ]; then
for x in \
/etc/wpa_supplicant/wpa_supplicant-"$interface".conf \
/etc/wpa_supplicant/wpa_supplicant.conf \
/etc/wpa_supplicant-"$interface".conf \
/etc/wpa_supplicant.conf \
; do
if [ -s "$x" ]; then
wpa_supplicant_conf="$x"
break
fi
done
fi
So there is these behaviour with wpa_supplicant-wlan0.conf and wpa_supplicant-wlan1.conf files "documented"
Thus you also don't need a reboot when changing. Just exec sudo systemctl restart dhcpcd