I have a setup where I have 3 Mikrotik Hotspots setup on RB411s. I am using the IP Hotspot and each device is acting as the server and authentication hub. I am only using a single user that I am allowing to login about 30 time simultaneous. So that way I don’t have to setup individual rules. Mostly I am using it for rate limiting. I am using http chap and cookie login. I would like to add a script that when a user connects to the hotspot, and then logs in successfully, I add the mac address of there computer to the http bypass page.
I know how to do some of it, but I am not sure how to get the MAC address of the client who is logged. in.
I can can the mac-address to the /ip hotspot ip-binding list and choose bypass. Please help me automate this process.
The user mac address is a two-part process. You need to get the user ip address from “/ip hotspot active”, then get the mac address for that ip in “/ip hotspot host” (to-address). Try this if you just need macs that are authorized:
:put [/ip hotspot host find where authorized];
This returns internal addresses (*xx,*yy, etc);
Then do a foreach loop to retrieve the mac for each entry, and check that each is bypassed.
I have a working script and will post it below in case anyone else needs it:
foreach a in [/ip hotspot host find where authorized] do={:local ln; set ln [/ip hotspot host get $a mac-address]; [ip hotspot ip-binding add mac-address=$ln type=bypassed]; }
I discovered that this script will not create duplicates, so I did not add any if statements for error checking. Thanks for your help Surfer Tim for getting me to this point!