How to connect different Wi-Fi interfaces to different networks in Linux

Using the GUI:

The easiest way to connect the Wi-Fi interfaces to different networks is through the GUI. When you click on the network symbol in the top right of the screen, it will give you a list of each Wi-Fi interface and you can pick a network for each one.

Using the Command Line:

If you are running the Raspberry Pi headless or can't connect a screen, then it is possible to configure the wireless networks on the command line using a tool called wpa_cli

When starting the wpa_cli, you can select the interface you want to configure using the -i argument.

For example:

wpa_cli -i wlan0

It will launch into an interactive mode where you can set options. From here you can confirm that the adapter is scanning and seeing networks by running:

scan

scan_results

That should show a list of the available wireless networks. Then you can add and configure a network, analogous to what you would put in the wpa_supplicant.conf file.

If you’ve already been playing with adding networks in the wpa_supplicant.conf file, you might want to remove them, or you can directly modify them with the wpa_cli tool.

Run

list_networks

to see any existing network configurations. If you already have one in the list, you can modify by using its ID in the command below. Otherwise, add a new network and take notes of its ID.

add_network

set_network <ID> ssid "The WiFi SSID"

set_network <ID> psk "password"

enable_network <ID>

If you have multiple network configurations, you might need to do:

select_network <ID>

If it is a simple network, that should be enough to get it to start connecting to the Wi-Fi network. You can save the configuration by running:

save_config

You can then quit out of the wpa_cli session and start it with the next interface and repeat the above steps.