Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Wpa-supplicant is not clearing its settings when I disconnect, and is overriding iwconfig on my next connection. These settings are persisting even through reboot - the only way to get back online is to take wpa-supplicant out of the pipeline.

I disconnect using a script which includes everything I could think of:

sudo dhcpcd --release "$INTERFACE"
sudo iwconfig "$INTERFACE" essid off
sudo iwconfig "$INTERFACE" ap off
sudo ifconfig "$INTERFACE" down

This worked well until I tried to integrate wpa-supplicant in it.

My "connect" script includes these lines, which I thought would clear out any remaining settings:

sudo killall wpa_supplicant 2>/dev/null
sudo rm "/var/run/wpa_supplicant/$INTERFACE" 2>/dev/null
sudo killall dhcpcd 2>/dev/null
sudo rm "/var/lib/dhcpcd/$INTERFACE" 2>/dev/null

How do I "reset" wpa-supplicant?

[edit]

I tried

wpa_cli -i "$INTERFACE" reconfigure

but that gave me

Failed to connect to non-global ctrl_ifname: wlp2s3  error: No such file or directory
share|improve this question
    
Try wpa_action "$INTERFACE" reload –  Sneetsher Feb 7 at 0:23
    
I'm getting wpa_action: command not found. –  operalala Feb 7 at 0:40
    
What distribution is this? How come they don't handle this seamlessly today? Have you looked for relevant bugs, or reported it? –  vonbrand Feb 7 at 1:01
    
Archlinux. Their forums are actually filled with unanswered WiFi problems, but it seems there should be some way to simply reset wpa-supplicant. –  operalala Feb 7 at 1:05
    
A lot depends on what configuration options wpa_supplicant and dhcpcd are called with - e.g. dhcpcd -p will it not to de-configure the device on exit. –  peterph Feb 7 at 1:20
show 2 more comments

1 Answer 1

It seems that wpa-supplicant is not in fact retaining its settings, but instead is OVERRIDING iwconfig, and the SSID I pass to it.

When I pass a non-wpa SSID to iwconfig, dhcpcd by default invokes wpa-supplicant for all WiFi connections, then wpa-s goes down ITS list of the wpa networks I configured for it, and decides that I don't really want the open network I asked for.

Putting a "wildcard" network config into wpa-s's config file causes wpa-s to simply pick the closest open network, no matter what SSID I pass to it.

Removing the "wildcard" causes wpa-s to error out on the first (out-of-range) wpa network on the list, ignoring my SSID entirely.

This appears to be a violation of the Linux rule "do one thing and do it well" - wpa-s seems to be mission-creeping into network management, and doing the worst possible job of it imaginable!

I fixed this by adding nohook wpa_supplicant to my dhcpcd config file, and changing my "connect" script to only invoke wpa-supplicant for wpa networks.

sudo iwconfig "$INTERFACE" essid "$SSID" key "$PSK" 2>/dev/null
WPA=$(printf "$TABLE" | grep "$SSID" | cut -s -d $'\t' -f 2- | grep "WPA")
    if [[ $WPA ]]; then
        sudo wpa_supplicant -B -D wext -i "$INTERFACE" -c "$WPA_SUPPLICANT_CONFIGURATION_FILE"`
    fi
sudo dhcpcd "$INTERFACE"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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