0

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).

BBridges
  • 37
  • 5

2 Answers2

1

Create a wpa_supplicant.conf for each interface: wpa_supplicant-wlan0.conf wpa_supplicant_wlan1.conf

Dirk
  • 3,372
  • 3
  • 16
  • 25
1

You have 2 issues.

  1. See Predictable Network Interface Names in How to set up networking/WiFi.
    No modern distribution relies on default port enumeration because the port allocation is subject to a race condition and unpredictable. (You can get away with it on a Pi because most users only have a single interface.)

  2. Depending on what you want to do with wlan0 (which is unclear from your question) see Prevent dhcpcd from configuring an interface,
    Prevent dhcpcd from configuring a gateway on an interface OR
    Use different wpa_supplicant files
    in the above.

Milliways
  • 54,718
  • 26
  • 92
  • 182