Wlan0: Deauthenticating by Local Choice

I'm trying to set up station mode on my device. It works fine if i give the wpa_supplicant command on command line after boot up. But disconnects when i give those commands in a script and then make a systemd service. And after it disconnects, wlan0 still has the ip address. and i have to flush it using ip addr flush dev wlan0. (Also, my wpa_supplicant executable is in /home/root.)

This works: Below are the commands which i gave manually on cli and i was able to ping. No issues.

/home/root/wpa_supplicant -B -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
dhclient -i wlan0

Or the script ./station_mode.sh can be ran instead and it gives no error. I'm getting the error only when i start the station.service which is given below.


This doesn't work - Same commands given in service throws error.

My script : station_mode.sh

#!/bin/sh

rfkill unblock all
/home/root/wpa_supplicant -B -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
dhclient -i wlan0

My systemd service: /etc/systemd/system/station.service

[Unit]
Description=station mode service.

[Service]
Type=simple
ExecStart=/bin/sh /home/root/station_mode.sh

[Install]
WantedBy=multi-user.target

Commands i gave:

systemctl stop wpa_supplicant
systemctl disable --now wpa_supplicant
systemctl start station

Output:

[ 2303.299834] wlan0: authenticate with be:37:a5:d8:96:36
[ 2303.334731] wlan0: send auth to be:37:a5:d8:96:36 (try 1/3)
[ 2303.344189] wlan0: authenticated
[ 2303.348966] wlan0: associate with be:37:a5:d8:96:36 (try 1/3)
[ 2303.369211] wlan0: RX AssocResp from be:37:a5:d8:96:36 (capab=0x1431 status=0 aid=1)
[ 2303.384351] wlan0: associated
[ 2320.245795] wlan0: deauthenticating from be:37:a5:d8:96:36 by local choice (Reason: 3=DEAUTH_LEAVING)

1 Answer

I did journalctl -f and found State 'stop-sigterm' timed out. Killing. that is dhclient is getting killed. Then i remembered that wpa_supplicant goes into background in my station_mode.sh script.

So,Type should be forking instead of simple in station.service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest