9/27/2019 - 1:05 AM

Wifi connection priority

Set wi-fi connection priorities

To list current priorities

$ nmcli -f autoconnect-priority,name c 
0                     Blake5Net             
0                     Caffe Ubuntu      
0                     Caffe Ubuntu Guest      
0                     Fire Hotspot          
0                     JET & Mishka             
0                     La Marzocco           
0                     Le_MX                 
0                     MobileLab             
0                     xfinitywifi           

Tip: If you have a very long list, you may want to sort them by priority:

nmcli -f autoconnect-priority,name c | tail -n +2 | sort -nr

How to set a network as preferred

nmcli connection modify "Caffe Ubuntu" connection.autoconnect-priority 10

Note that you can use any number you want for the priority. A larger number moves the network to the top of the list.

How to set a network as a last resort

nmcli connection modify "xfinitywifi" connection.autoconnect-priority -10

Negative priority values are lower than the default of 0, which means they will be tried last, if no other known WiFi network can be found. Note that, due to a bug in some versions of nmcli, you may see negative numbers listed as huge positive numbers like 4294967286. Don't worry about this as it will still work fine.