I configured wpa_supplicant so I have a wifi connection after boot up. Now I want to stop it for while and start it again. I tried:

rpi ~$ sudo ifdown wlan0
ifdown: unknown interface wlan0

But wlan0 exists:

rpi ~$ ip addr show dev wlan0
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:06:e8:8b brd ff:ff:ff:ff:ff:ff
inet brd scope global wlan0

Trying to use systemd also fails. wpa_supplicant.service is already disabled:

rpi ~$ systemctl status wpa_supplicant.service 
● wpa_supplicant.service - WPA supplicant
   Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

I have looked at /lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant but cannot figure out how to use it.

  • It's an actual program and you can kill it, although if you are using the system networking stuff there's a good chance something will just start it up again. You're also running a dhcp client on that interface, and that is a program you can kill or stop (dhclient or I think dhcpcd; with the former you can use dhclient -r to stop it) but the same caveat probably applies. – goldilocks Jul 3 '18 at 14:28

After a while now I understand how it works. wpa_supplicant is managed by dhcpcd using a hook. Neither ifupdown networking, managed with /etc/network/interfaces, is involved nor the systemd service. wpa_supplicant.service is completely ignored by dhcpcd and has no functionality. To stop/start wpa_supplicant you have four possibilies.

If you want to quick stop/start temporary the wifi connection you can just down/up the interface. This will not stop wpa_supplicant. It is still running in the background and can respond to other requests. I use wpa_cli to control wpa_supplicant.

rpi ~$ sudo ip link set dev wlan0 down
rpi ~$ wpa_cli ping
rpi ~$ sudo ip link set dev wlan0 up

If you want that wpa_supplicant does not do anything to be sure that there are no side effects with wifi you can terminate it completely. To start it again you have to restart dhcpcd:

rpi ~$ wpa_cli terminate
Selected interface 'p2p-dev-wlan0'
rpi ~$ wpa_cli ping
Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
rpi ~$ sudo systemctl restart dhcpcd.service

If you want to disable wlan0 persistent to be used by wpa_supplicant you can add this line to /etc/dhcpcd.conf. It will also do not start wpa_supplicant if there is no other wifi interface available. Otherwise it is started to manage other wifi interfaces.

denyinterfaces wlan0

If you want to disable wpa_supplicant in general you can add this line to /etc/dhcpcd.conf:

nohook wpa_supplicant
| improve this answer | |

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.