0

(I'm intentionally imprecise with the actual steps i've tried because there are hundreds of things - I know because I looked at the size of my BASH history)

CentOS 7, NetworkManager

(Please correct anything i'm wrong about below)

A customer has an environment with multiple APs having the same SSID. I have to write a BASH script that connects a linux box to each AP in turn, executes a command to gather data, then moves on to the next AP, wash, rinse, repeat. The BSSID is the obvious thing to use to connect. The script qua script is working beautifully, but the BSSID-based wifi connection bit is not.

I have tried iw, iwconfig, nmcli, and wpa_supplicant and cannot get it to reliably connect to the BSSID I specify - regardless of what I put in the command the actual BSSID connected to just seems to be random. From what I have gathered, all of these tools, aside from wpa_supplicant, just take the BSSID, associate it with an SSID, then use the SSID in the connection setup, which, if correct, seems kinda stupid (to be blunt).

wpa_supplicant is just too fragile to use this way - it always gets into a state where wpa_cli cannot connect and I have to continually restart it and often restart NetworkManager.

I thought about switching to Python, but the Python modules just seem to be wrappers to the linux commands, so nothing changes.

If anyone has any ideas please pass them along. I cannot believe that this is so difficult, so I must be missing something obvious...

I tried Eduardo's solution below.

I cannot implement this exactly as provided. I'm running the connection attempt in a loop in a shell script where the MAC address / BSSID is a variable (SSID and password/psk are static).

The command i'm using to connect is:

nmcli connection up ifname wlp4s0 ap $AP passwd-file passwdfile

where passwdfile contains the psk. This is in a loop through the list of $AP.

It still connects to a random AP from the list. (Probably the one that at that instant had the best signal), and more confusing (to me) is that iw event shows a different connected BSSID than

nmcli -f SSID,BSSID,ACTIVE dev wifi list | grep yes

There must be something really obvious i'm not doing correctly (this is still mostly new to me).

2
  • Is it absolutely necessary to connect through Wi-Fi instead of LAN using IP addresses? Mar 30, 2023 at 19:30
  • yes - the purpose is to gather some stats from the APs about the wifi connection to the test device, so it has to connect. And i think to use the IP via ethernet the target IPs would have to be configured ahead of time. I get the ssid/bssid automatically using a scan. The idea is to have a standard load for the test devices that requires little to no config before they are deployed - ship it to the customer, plug it in, and go.
    – msampson
    Mar 31, 2023 at 20:08

2 Answers 2

1

If you only provide the normal ascii password then wpa_supplicant needs to find out the SSID, because the 64 hex digits PSK (kind of the actual password) is derived from it. At this moment it goes into SSID mode.

So the solution is to specify just the BSSID and the 64 hex digits PSK password.

You can get the 64 hex digits PSK by running:

wpa_passphrase YourSSID YourAsciiPassword

For example:

$ wpa_passphrase Example myexample
network={
    ssid="Example"
    #psk="myexample"
    psk=e22b519be7138dce1d81d1b67b622a720774f22753f79f954376e6e2b722e2c7
}

Then you use BSSID instead of SSID and end up with something like this:

network={
  bssid=EE:FF:00:01:02:03
  psk=e22b519be7138dce1d81d1b67b622a720774f22753f79f954376e6e2b722e2c7
}

That should connect you just to that BSSID.

3
  • great - i will give that a try and see what happens.
    – msampson
    Mar 31, 2023 at 20:02
  • Thanks for a very informative comment. Here is a question, though. Is there any difference between entering this information in wpa_supplicant,conf and entering it in an application such as nm-connection-editor? 2 days ago
  • This answer continues to intrigue me but I don't fully understand it. The device I'm trying to modify is a Raspberry Pi5 running ArchLinux. This system does have wpa-supplicant installed and it is running, but none of the other possible networks, including the parent network is listed in /etc/wpa_supplicant.conf. Are you suggesting that the bssid-based network block be added to wpa_supplicant.conf? And if so, how (under what name) would this network show up in the system's list of networks. 2 days ago
0

My use case is a little different, but I do want to extend hearty thanks to Eduardo Trápani who got me on the right track with his solution. My use case is a Google Nest router-access point pair, with the main router upstairs next to the modem, and Nest AP downstairs in a window, pointing outside to my Raspberry Pi 5 which controls my telescope.

This part of Eduardo's solution is absolutely necessary:

$ wpa_passphrase Example myexample
network={
    ssid="Example"
    #psk="myexample"
    psk=e22b519be7138dce1d81d1b67b622a720774f22753f79f954376e6e2b722e2c7
}

That step is essential. But I was not sure what to do with the network snippet he created from the output of the wpa_passphrase command:

network={
  bssid=EE:FF:00:01:02:03
  psk=e22b519be7138dce1d81d1b67b622a720774f22753f79f954376e6e2b722e2c7
}

It turned out to be incredibly simple. I just add a network in the Network GUI on the system and fill it out with the BSSID being the mac address of my Access point and the password being the output of the wpa_passphrase command. It just works, and my mbps went from 8 to 245!

My original Network was Hannah, and although the Pi should have found the better connection, for some reason, it didn't. But with the second network Hannah-2 now defined as indicated above, it finds it easily.

wifi setup main page Hannah-2 config

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .