Any way to use roaming in Network-Manager but still set a preferred network?

Asked by Stephen Gornick

When in roaming mode Network-Manager connects on startup to the wrong access point.

Is there any way to specify a preferred network (or even better, a list of preferred networks)?

There are a number of discussions on the topic, but no solution other than setting an essid manually in /etc/network/interfaces :

http://tinyurl.com/3ymy7k
http://tinyurl.com/37ayje
http://tinyurl.com/3ad5my
http://tinyurl.com/3bv7nb

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Jim Hutchinson
Solved:
Last query:
Last reply:
Revision history for this message
Jim Hutchinson (jphutch) said :
#1

I see this issue pop up quite often, but to my knowledge there is not a standard solution. What is interesting is that I have never had this problem. At home, my laptop always just connects to my network and when out and about it will grab the one it has "seen" before (i.e. one I've connected to before). I recently added a second wireless AP at home and my laptop still defaults to the one I've always used. The reason I mention this is because there may be something in my setup that encourages the desired behavior. However, I really don't have a clue what that could be. I do have a poor guess.

I'm wondering if it relates to security and the keyring. I have security on my AP and when I first connect I have to give the AP passphrase and then give a password to store that passphrase in the keyring. After that, whenever I boot up the laptop it asks for the keyring password shortly after logging in. I wonder if that causes NM to look for the AP associated with the stored passphrase or if it asks for the password because it's trying to connect to the secured AP. What is interesting is that it has not tried to connect to the second AP I just set up even though it has as strong a signal as the other one. However, this doesn't really explain the tendency of NM to grab an open AP when at a coffee shop (even when there is more than one). It's possible that NM "remembers" APs that I've connected to and gives them preference. What I don't know is how to enable that behavior. It's always "just worked" for me.

I don't suppose there is much useful here but maybe someone will see a familiar patter and be able to suggest something.

By way of something more helpful, check out this:

https://help.ubuntu.com/community/WifiDocs/NetworkManager#head-d2b310228dc887b6cddf4465b6a53cdc4dc9be28

Revision history for this message
Stephen Gornick (sgornick) said :
#2

> It's possible that NM "remembers" APs that I've connected
> to and gives them preference.

I do know that the ESSID that Network-Manager does connect to automatically is one that I had connected to prevously, however I now want it to connect automatically to a different one. Both have no WEP/WPA keys. The one that I don't want to connect to has a higher quality rating than the one I do want to connect to (as shown by iwlist) so maybe Network-Manager factors signal quality in the mix as well?

Revision history for this message
Best Jim Hutchinson (jphutch) said :
#3

Maybe delete the one you don't want from the gconf-editor. The link above described how to edit that. Not sure it will work, but it's worth a try.

Revision history for this message
Stephen Gornick (sgornick) said :
#4

Thanks Jim Hutchinson, that solved my question.

Revision history for this message
Stephen Gornick (sgornick) said :
#5

(from the Link that Jim pointed me to ...)

Network Manager will automatically reconnect to any network it finds nearby that is stored in GConf. The order of preference is based on the time you last connected. To access these details open gconf-editor.
gconf-editor

Now navigate to system -> networking -> wireless -> networks. There you will find separate directories for each network under it's network name (essid).
Preventing automatic connection to particular networks

In gconf-editor select the essid of the network you wish to edit. For each of the keys, right-click the key and select Unset Key... Once done quit gconf-editor. If you reopen gconf-editor, you will now see that the network has been removed. This will only prevent automatic connection to a network, you can manually re-connect at any time.

https://help.ubuntu.com/community/WifiDocs/NetworkManager#head-d2b310228dc887b6cddf4465b6a53cdc4dc9be28

Revision history for this message
Jim Hutchinson (jphutch) said :
#6

Cool. Glad to hear it worked.

Revision history for this message
John McCain (mccainj) said :
#7

Network Manager's behavior is OK as long as there is only one logical choice. That isn't the case for me.

At work, I connect to the wired internal network. But there is also a wireless access system that provides guest access to the internet via a different IP network. It is a total crapshoot as to which network I will connect to. I cannot seem to govern this behavior in any way. I attempted to use the gconf-editor solution to remove references to the guest network, but this was completely ineffective.

If I connect to the guest network, I must take the following steps to get things working correctly:

disable the wireless network from within Network Manager. This drops the address and the gateway routing information for the guest network, but my name servers will still be wrong in /etc/resolv.conf

I must then open a terminal and launch an instance of dhclient against the eth0 interface to get my name servers right.

The idea of "it just works" is fine, and I see the value of that, but I should be able to do one or both of the following:

-Network Manager must behave in a deterministic (and preferably configurable) way.
-When I disable the wireless network in Network Manager, it should be smart enough to know that my name servers are wrong and update /etc/resolv.conf.