4

Is there a way to disconnect from a network via wpa_cli? I'm reading the man page and I've been able to use wpa_cli to connect to my router via push-button connect (WPS); however I'm trying to write a script that will disconnect from the network upon a certain event.

I attempted to find the network via nmcli but the network I'm connected to doesn't even show up when invoking the nmcli connection show -active command. Many thanks.

GAD3R
  • 63,407
  • 31
  • 131
  • 192
CAPGuy
  • 83
  • 2
  • 2
  • 4

2 Answers2

5

Just do wpa_cli disconnect to disconnect, and wpa_cli reconnect to connect again.

Alternatively, you can also ifdown/ifup your wlan interface.

BTW, the man page of wpa_cli for some reason only lists a few commands; use wpa_cli help for a much longer list.

(I can't help you with the nmcli issue).

GAD3R
  • 63,407
  • 31
  • 131
  • 192
dirkt
  • 31,679
  • 3
  • 40
  • 73
1

To disconnect from the network via wpa_cli you can use the following commands:

disable_network <network id>

It is used to disable the network

disconnect

disconnect and wait for reassociate command before connecting

 terminate

terminate wpa_supplicant

edit

the network I'm connected to doesn't even show up when invoking the nmcli connection show -active

You should save your configuration through save_config command.

GAD3R
  • 63,407
  • 31
  • 131
  • 192
  • "disable network" only excludes one particular network (i.e. BSSID) from the list of networks to automatically connect to. While this would also work, it's probably not what is wanted. – dirkt Oct 05 '16 at 11:05