I am trying to find a way to disconnect unauthorized hotspot users. We use the Mikrotik hotspot as centralized controller for a number of wifi hotspots. However if a user is not authorized they tend to get a hung session that must be manually removed from the hotspot host list and I'd like to automate this in some fashion.
I tried using this script and various other versions of something similar:
/ip hotspot host remove [/ip hotspot host find where !authorized]
This has no effect. In fact just attempting to get a list of unauthorized hosts using something like /ip hotspot host find where !authorized does not print any results on the CLI (should it?). I can get a list of unauthorized hosts if I use something like /ip hotspot host print where !authorized, but I don't know how to extract the ID out of this to remove the host.
[admin@Mainstreet Office - Ross Test] /ip hotspot host> print where !authorized
Flags: S - static, H - DHCP, D - dynamic, A - authorized, P - bypassed
# MAC-ADDRESS ADDRESS TO-ADDRESS SERVER
0 H 00:26:B9:AD:57:C8 192.168.5.238 192.168.5.238 hotspot1
I also attempted to remove the user using a radius disconnect message (since we have centralized radius authentication/authorization anyway).
However a radius disconnect fails:
# echo -e "NAS-IP-Address=172.17.0.5\nFramed-IP-Address=192.168.5.238" | radclient -r 1 172.17.0.5 disconnect secret
Error message: "Radius disconnect request for unknown ip 192.168.5.238"
(Note that sending the same disconnect message for the host when it is authorized results in the host being properly disconnected)
Attempting to send a DM using the User-Name or Calling-Station-Id instead results in an error message on the Mikrotik that states "Radius disconnect with no ip provided"
I attempted to add additional information such as the hotspot nas port and username along with the Framed IP but this also fails stating that the IP can not be found.
Running v3.30
How can I clear out those unauthorized hotspot hosts without having to do it manually?