I have a pi at a remote location to which I VNC or SSH into regularly. I had to purchase a https://store.rokland.com/pages/alfa-awus036acm-driver-support-page wifi adapter because the current wifi adapter wasn't strong enough. Its installed and working.
The problem is I have to go to the pi and manually configure wlan1 (aka: wifi adapter) to connect to the network after a reboot.
If I update wpa_suppplicant.conf by adding the SSID and key, then wlan0 connects to the network automatically at boot, not wlan1. If I tell wlan0 to forget the wifi network it deletes the network from wpa_supplicant.conf.
I tried writing a script that manually connects wlan1 to my network. If I run it manually after a boot, it works as expected. I can start the script and wlan1 connects to thee wifi. If I kill wlan1 disconnects. I thought maybe this would be the solution. I added it to rc.local to run at boot and it didn't work. I then added a delay to the script, giving the PI time to bootup before executing the connection commands. This also didn't work.
#!/bin/bash
args=("$@")
sleep 120
echo $1
if [ $# -eq 0 ]; then
echo "Please provide a network you would like to connect too"
elif [ $# -eq 1 ]; then
if grep -q "mynetwork" "/etc/wpa_supplicant/wpa_supplicant.conf"; then
echo "found it"
sudo wpa_supplicant -c /etc/wpa_supplicant.conf - wlan1
else
echo "not found"
wpa_passphrase "mynetwork" "password" | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf
sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan1
fi
fi
I'm looking for suggestions on how at boot I can connect wlan1 automatically to a wifi signal and not wlan0.
An additional note: if wlan0 and wlan1 are both connected to the same network, I am no longer able to access it via ssh on wlan1's IP address (which seems strange to me).