11

When an Operating System has several wireless networks available (and known, this is: in its "preferred" list), it is supposed to do an intelligent management of roaming between them, usually connecting to the best one (measuring it by several factors, like coverage or speed).

But, when working with some Linux distros (for example the intended for security auditing ones), I have found such management not so intelligent: sometimes the net keeps down (not behaving completely OK) and the operating system stays on that wireless network.

So, I was thinking about doing a script myself to force Linux to select another wireless network when the connected one slows down or directly fails (maybe checkable by pinging the router/access point).
For what I have read about command-line wireless management, the "connect to" thing seems a bit awkward.

Does anyone know about a good "switch-to-network" command-line tool running under Linux? Remember I don't need to connect to a new network: I just want to connect to an already-some-day connected network, so the operating system is supposed to know the password, encryption data and so on.

Possible command-line examples:

switchtowifi --essid MyWiFiNetwork
switchtowifi --essid MyWiFiNetwork --bssid 11:22:33:44:55:66
switchtowifi --channel 5

The first example switches to any already-stored WiFi network named MyWiFiNetwork.
The second example switches to the already-stored WiFi network named MyWiFiNetwork whose BSSID is 11:22:33:44:55:66.
The third example switches to any already-stored WiFi network on channel 5.

6

Hopefully this isn't too late to be useful; but I have a similar requirement due to having more than one AP at home (including testing some, my primary connection, and a segregated work LAN yadda yadda...)

One of the issues in this question, is that there's no mention of your Distro, wireless utilities used, method for configuring your known networks etc. That aside, from what I can see, there's nothing of this sort available at the moment, without using something like wicd-gtk etc.

Personally, although I use Ubuntu as I like the package/distro management, I hate Gnome/KDE etc, and opt for Fluxbox, which renders the normal Wifi utilities a little pointless/useless.

So; after disabling network manager so it doesn't interfere, I hand configured the networks I need using the details at: http://linuxcommando.blogspot.co.uk/2013/10/how-to-connect-to-wpawpa2-wifi-network.html

The configuration files for each network I placed into a new directory in /etc/wpa_supplicant.d/SSID_HERE.conf and then made a little script in /usr/local/bin/connectwifi which (although a rough WIP!) can be found here: http://dgunix.com/383-switching-between-wifi-networks-in-linux/

Hopefully that gives you some ideas at least!

4

(Answer found at the Unix & Linux StackExchange site)

Solution using the nmcli tool, included in most distros or easily installable via apt-get, yum ... etc :

To show already-stored WiFi networks:

$ nmcli con
NAME            UUID                                   TYPE              TIME
Wireless-1      28d6c265-xxxx-4e83-907f-ecb5ab3ac37c   802-11-wireless   Thu 
Wired-Network   30d29da3-xxxx-4ea2-94ff-0edac8954ff7   802-3-ethernet    Sun 
Wireless-2      89f31b44-xxxx-4b7d-abb1-8242a1fa7040   802-11-wireless   Thu 
Wireless-3      6adcb4e8-xxxx-4e88-bf50-872d9e5eb1f3   802-11-wireless   Fri 
Wireless-4      8c4fc701-xxxx-472e-aecc-40131c0d8d31   802-11-wireless   Fri 

Note the network is stored by a unique UUID identifier.

To connect to any of these networks (example for Wireless-1):

$ nmcli con up uuid 28d6c265-xxxx-4e83-907f-ecb5ab3ac37c

See the man page for more functions, like forget, disconnect, scan or connect to new (not yet stored) network.
The nmcli tool is great: it can work with a specific wireless device (i.e: wlan0) or with any of them in a generic manner (i.e: you just specify wifi and the tool makes in charge of establishing the connection).

Info extracted from here.
Thanks to @ThatGuy for the link.

3

You can try:

  • iw which is the basic tool for WiFi network-related tasks (See: Wireless network configuration)
  • Wireless Tools (WT): iwconfig/iwlist (set of tools allowing to manipulate the Wireless Extensions),
  • wpasupplicant (most distributions nowadays have wpa_supplicant installed by default)

Read more:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.