It's April, 2022, and this question of "How to setup multiple WiFi networks?" now has a straightforward answer:
If you use multiple WiFi networks in different locations, all that is needed is to configure each of these networks in the file /etc/wpa_supplicant/wpa_supplicant.conf
- configure as many as you need!
The wpa_supplicant.conf
file proposed in the currently selected answer is still correct, though the id_str
is optional:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SCHOOLS NETWORK NAME"
psk="SCHOOLS PASSWORD"
}
network={
ssid="HOME NETWORK NAME"
psk="HOME PASSWORD"
}
Unless you are "Home Schooled", which is to say that two or more networks are available in a given location, it's not necessary to create a priority
for the networks :) By default, all networks listed in wpa_supplicant.conf
have equal priority, and when priority is equal
wpa_supplicant
will choose the network with the greatest signal strength (all other things being equal). This will come as a disappointment to the knob turners, but beyond properly defining the networks in wpa_supplicant.conf
, there is really nothing else to be done in the situation defined by the OP.
If you do have two or more networks in a given location, then a priority
assignment to your "favored" network may be appropriate. Another exception may be that you have a need to switch between networks. If you need to dynamically switch between networks, - there's another answer for that. Otherwise, leave it alone.
Readers should carefully consider adopting networking advice in a piecemeal fashion; there are numerous fallacies and foolishness embedded in some of the answers and comments here. Some that I noticed:
And there are others, but impossible to list them all here. Be diligent - and that goes for this answer also!
wpa_supplicant
will choose the network with the strongest signal; i.e. the selection will be done automatically as long as thewpa_supplicant.conf
file contains the specs for the networks. – Seamus Apr 06 '22 at 05:12