LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   wpa_supplicant keeps auto-changing my wireless network (https://www.linuxquestions.org/questions/linux-networking-3/wpa_supplicant-keeps-auto-changing-my-wireless-network-4175659283/)

skubik 08-17-2019 02:39 AM

wpa_supplicant keeps auto-changing my wireless network
 
I'm running Slack64 14.2 and am encountering a situation where wpa_supplicant keeps auto-connecting to my top/default network even when I explicitly connect to a different network.

That is, I have 'Network 1', 'Network 2' and 'Network 3' defined in my wpa_supplicant.conf. it automatically connects to 'Network 1', but whenever I select 'Network 3' (for example), it automatically kicks back to 'Network 1'.

I have some scripts written that I use to connect to wireless networks invoking wpa_supplicant directly, but I've also tried using NetworkManager and have the same result.
I've used my scripts on other machines with slightly older installs of Slack64 14.2 and haven't had a problem until I installed them on this machine (ThinkPad X1 Carbon circa 2012).

Any suggestions on why this might be happening?
Thanks in advance.


I've included my wpa_supplicant.conf, below:
Code:

# This line enables the use of wpa_cli which is used by rc.wireless
# if possible (to check for successful association)
ctrl_interface=/var/run/wpa_supplicant

# By default, only root (group 0) may use wpa_cli
ctrl_interface_group=0
eapol_version=1
ap_scan=1
fast_reauth=1

#update_config=1
#country=US



network={
        ssid="Network 1"
        psk=dls93932lasklkdasld932932012e23jr375t457djd83838ol2838ekdudjksk5
}

network={
        ssid="Network 2"
        psk=kdi3833lkqlqkdjjvhskdj38383kqkskddjkjsdncskaw88384u5ogflgjudkse4
}
network={
        ssid="Network 3"
        psk=irilslsls9d4k49fdlifdkgdfigjserngf45utse8p48e4rkr949494leldrf98d
}


business_kid 08-17-2019 12:59 PM

According to the man page wpa_supplicant might be doing what it's supposed to. The thing that will tell you is a wifi scan
Code:

iwlist wlan0 scan |grep -e 'SSID' -e 'Quality'
That ought to do it. If the network you're on has the best Quality, it might be doing it's job.

If you want to nobble that, the first thing I would try changing this line in your config
#update_config=1
to something like this:
update_config=0

If the sky falls in you reverse that, but it might help. You could also try changing the order in your config file.

permaroot 08-17-2019 01:16 PM

Quote:

Originally Posted by business_kid (Post 6026168)
According to the man page wpa_supplicant might be doing what it's supposed to. The thing that will tell you is a wifi scan
Code:

iwlist wlan0 scan |grep -e 'SSID' -e 'Quality'
That ought to do it. If the network you're on has the best Quality, it might be doing it's job.

If you want to nobble that, the first thing I would try changing this line in your config
#update_config=1
to something like this:
update_config=0

If the sky falls in you reverse that, but it might help. You could also try changing the order in your config file.

http://www.qnx.com/developers/docs/q...upplicant.html

According to that site the update_config=1 allows wpa_cli to update the config. I don't think it has anything to do with switching APs based on quality of signal.

But I think you are right. wpa_supplicant seems to be designed to do that.

permaroot 08-17-2019 01:38 PM

What do your scripts to connect to your networks via wpa_supplicant look like?

What I'm getting at is that when you call wpa_supplicant you are pointing to your config at wpa_supplicant.conf right?

If so you can make a config file for each network and point to that in whatever script you are running?

skubik 08-18-2019 02:29 AM

Quote:

Originally Posted by permaroot (Post 6026187)
What do your scripts to connect to your networks via wpa_supplicant look like?

What I'm getting at is that when you call wpa_supplicant you are pointing to your config at wpa_supplicant.conf right?

If so you can make a config file for each network and point to that in whatever script you are running?

Yes, this is definitely possible in my scripts. It's late now so I'll have to try this tomorrow, but I imagine it will work.

However, after spending part of the day today playing with it and looking at debug output and output in wpa_cli, I'm still unsure as to why this is happening at all.
I looked at versions and I am currently using wpa_supplicant v2.6, whereas the previous system I ran these scripts and my wpa_supplicant.conf on was using v1.0. I skimmed over the changelogs for wpa_supplicant and it looks like there's a lot that changed between 1.0 and 2.0, but I wonder if there's something specific that was added after 1.0 that makes it behave like it is for me now versus how it used to behave on my old system.

Also, changing which config file my scripts point do doesn't resolve the problems I'm having with NetworkManager that keeps changing what network I'm connected to anyway. (My scripts do not invoke NetworkManager itself, but I have an option that starts the NetworkManager service if I choose to use it for times when I need to connect to, say, public wifi)

I've browsed sample wpa_supplicant.conf files and there's a lot of stuff in there. Anything I should specifically be looking at?

Thanks

permaroot 08-18-2019 04:06 AM

Quote:

Originally Posted by skubik (Post 6026340)
Yes, this is definitely possible in my scripts. It's late now so I'll have to try this tomorrow, but I imagine it will work.

However, after spending part of the day today playing with it and looking at debug output and output in wpa_cli, I'm still unsure as to why this is happening at all.
I looked at versions and I am currently using wpa_supplicant v2.6, whereas the previous system I ran these scripts and my wpa_supplicant.conf on was using v1.0. I skimmed over the changelogs for wpa_supplicant and it looks like there's a lot that changed between 1.0 and 2.0, but I wonder if there's something specific that was added after 1.0 that makes it behave like it is for me now versus how it used to behave on my old system.

Also, changing which config file my scripts point do doesn't resolve the problems I'm having with NetworkManager that keeps changing what network I'm connected to anyway. (My scripts do not invoke NetworkManager itself, but I have an option that starts the NetworkManager service if I choose to use it for times when I need to connect to, say, public wifi)

I've browsed sample wpa_supplicant.conf files and there's a lot of stuff in there. Anything I should specifically be looking at?

Thanks

I haven't found any option that would disable this behavior.

I would follow business_kid's advice and check the quality/signal strength of each AP and see if it is indeed switching to the one with the best strength/quality.

If this is the case, take a look at the man page for iwconfig.

Specifically the sens parameter. Apparently modern WiFi cards will choose another AP under poor conditions.

The sensitivity can be changed with iwconfig wlan0 sens -80 to set the threshold, for example. If you set it low enough this could fix your issue.

Something to look at and play around with if AP signal strength is determining the AP change.

skubik 08-18-2019 09:38 PM

Well, if there's no way to disable that behavior, then I guess I'm stuck with modifying my scripts, which I've done, and it seems to work perfectly.

There's still a part of me that is very unsatisfied with this approach, but it is what it is.

Thanks for your help.

permaroot 08-18-2019 09:54 PM

Quote:

Originally Posted by skubik (Post 6026687)
Well, if there's no way to disable that behavior, then I guess I'm stuck with modifying my scripts, which I've done, and it seems to work perfectly.

There's still a part of me that is very unsatisfied with this approach, but it is what it is.

Thanks for your help.

Glad you sort of resolved it. I guess I’ve never been in range of more than one AP I want to connect to so I’ve never had to deal with this.

I can connect/save info to another close AP at school and see if I can replicate the behavior. Without replicating it and tinkering having a different config for each one is all I can think of.

If I find anything out I’ll let ya know.


All times are GMT -5. The time now is 11:38 PM.