Disconnect Client from WiFi using CLI

Hello,

I want to disconnect a client, based on IP or mac using CLI. I don't want to ban, just disconnect.

The reason,
Today I found one of my devices unreachable. Disconnecting it from WiFi usually (and also today) makes the device connect to one of my other Access Points and all will work again.

I need to investigated, but if this happens more to a device I want to be able to disconnect this using a script.

1 Like

I would try hostapd_cli -i <ifname> disassociate <addr>

-i<ifname> Interface to listen on (default: first interface found in the socket path)

hostapd_cli interface will give you the list of interfaces.

ubus call hostapd.<ifname> del_client "{'addr':'<mac_addr>', 'reason':5, 'deauth':true, 'ban_time':2000}"

Ban time is in milliseconds (2 seconds in the example).

1 Like

I tried that one, it return ok, and a physical address, but does not disconnect.

What do I use for ifname?
because I always get this

root@OpenWrt:/etc/config# ubus call hostapd.lan del_client "{'addr':'<my mac>', 'reason':5, 'deauth':true, 'ban_time':1000}"
Command failed: Not found

where the address is clearly listed under " Associated Stations" in Luci

You may need to specify the interface name. Run the program with --help to see all the options and commands.
I've updated the above example.

wlanX, phyX-apY or whatever the name of the Wi-Fi interface is:

ubus call hostapd.phy0-ap0 del_client "{'addr':'8E:90:14:13:0C:5A', 'reason':5, 'deauth':true, 'ban_time':2000}"
3 Likes

ubus list hostapd.*

2 Likes

thnx
phy0-ap2
in my case

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.