Wifi Order of connecting

Hi All,

When you have multiple WIFI connections, can you determine the order in which the ASl attempt to connect???

73 de Angelo / N5UXT

"multiple wifi connections" --> all the same SSID? or different SSIDs?

I believe that without a priority number they will attempt in order written, then back to the top when exhausted. It does not pay to have to many for if you are portable, you 'may' do some waiting till the one you want is tried.

You will need to read the current doc's on the file creation on priority..

"nmcli -f NAME,UUID,AUTOCONNECT,AUTOCONNECT-PRIORITY c" to see a list of every Wi-Fi network your Pi remembers and what their current priority is.

NetworkManager uses a simple numbering system to decide which network to connect to: the highest number wins. By default, every new Wi-Fi network you add has a priority of 0. If multiple networks are in range and they all have a priority of 0, the Pi just randomly guesses. I have a mobile node in my vehicle, which has battery backup. When it's in the vehicle it connects to my phone's hotspot. When I bring it into my house, it usually has ethernet cable plugged into it. So I've made the highest priority the wired ethernet in my house, then my phone's hotspot, and lastly my home's WiFi.

"sudo nmcli connection modify "YourHomeNetworkName" connection.autoconnect-priority 100" makes my ethernet connection top priority.

"sudo nmcli connection modify "YourPhoneHotspotName" connection.autoconnect-priority 50" makes my phone's hotspot next priority.

"sudo nmcli connection modify "HomeNetworkName" connection.autoconnect-priority 10" makes my home WiFi, the lowest priority.

I've also set the number of tries the node will attempt to connect to a network before going to the next one. That's another subject, so I'll stop here.

Different SSID's. All wireless.

There are two ways of doing this that I know of.

Look in the /etc/NetworkManager/system-connections directory. You should have a .nmconnection file for each configured network.

For each connection, edit it's corresponding file and add priority in the connection section. A higher number of priority will connect sooner if available, just like with the older way of doing things with wpa_supplicant.

Let's say, for example, you have a configured connection called "MyPhone". If you edit /etc/NetworkManager/system-connections/MyPhone.nmconnection, you could see something like this:

[connection]
id=MyPhone
uuid=blahblah-blahblah-blah-blah
type=wifi
interface-name=wlan0

Add priority before the interface=line. I will use 999 as an example of highest priority. It would look like this after the change.

[connection]
id=MyPhone
uuid=blahblah-blahblah-blah-blah
type=wifi
autoconnect-priority=999
interface-name=wlan0

Then edit the nmconnection file for each network, and add a number lower than that one in priority for each one in the same way. It will always start from highest to lowest priority when autoconnecting.

Another, perhaps easier way is to use nmcli to edit the connection. For example, you can change the priority of MyPhone like this:

sudo nmcli c modify MyPhone connection.autoconnect-priority 999

then change MyHome to a lower priority:

sudo nmcli c modify MyHome connection.autoconnect-priority1

Sorry for possible bad formatting. I am having real trouble with the text edit box and screen reader accessibility when trying to do cool things like code blocks.