Using wpa_supplicant with bssid instead of ssid

Hi all. I’m using wpa_supplicant to declaratively manage the connection with a number of networks.

The last few days I have been running into trouble because I regularly connect to two separate networks (that I do not control) that have the same SSID.

Using the options described here, I cannot define the same SSID twice.

Outside NixOS, you would use the BSSID (which I believe is the same as a device’s mac address). But when configuring wpa_supplicant declaratively, using these options, there seems to be no way to use the BSSID instead of the SSID?

Has anyone else encountered this issue? What could be a solution?

You can use extraConfig to set this kind of thing. e.g.:

networking.wireless.networks.mywifi = {
  extraConfig = ''
    bssid=00:11:22:33:44:55
  '';
};
1 Like

But then “mywifi” is still the ssid right? So if I have two (or more) networks with the same ssid (let’s say “mywifi”), I would still have multiple values for networking.wireless.networks.mywifi.extraConfig? Which is not possible?

Hah, yes, I overlooked that, my bad. Most modules with features like this let you override the attribute name in the options, but not this one.

I’d give setting the ssid in the extraConfig a shot, there’s a good chance wpa_supplicant just takes the last defined value. If it doesn’t, this is an oversight in the module, and someone will need to fix this upstream. Should not be a hard patch if you’re willing to give it a go.

If you end up having to wait for that, give NetworkManager a shot, especially if you’re setting up a desktop. With ensureProfiles you get declarative config too, and I find it is much more suited to desktop use cases.

I’ve honestly come around to the idea that NetworkManager should be the go-to for wireless networking in general, even on servers/IoT things, systemd-networkd doesn’t feature support for wireless networking and raw wpa_supplicant has its issues.

1 Like

Thanks for the elaborate reply again.

I’ll give it a last check tomorrow, but I think you found the trick: it looks like I can use any name for the SSID, and then simply redefine it in the extraConfig.

Just got the chance to test it, and yes it works.

So just for whoever ends up here as well: when you have two networks with the same ssid, let’s say “mywifi”, you can declaratively connect to both networks like this:

networking.wireless.networks = {

"some_made_up_name" = {
extraConfig = ''
ssid=mywifi
bssid=real_bssid
'';
};
"some_other_made_up_name" = {
extraConfig = ''
ssid=mywifi
bssid=other_real_bssid
'';
}

By the way: the reason why I’m using wpa_supplicant instead of NetworkManager is because - as far as I know - I need the former to connect to Eduroam at the University of Amsterdam.