Community discussions

MikroTik App
 
electravis
Member Candidate
Member Candidate
Topic Author
Posts: 274
Joined: Tue Jan 26, 2010 12:06 am

running script after hotspot login

Sat Apr 07, 2018 12:07 am

So Im trying to make a script hat after the user logs in here IP address gets added inot he firewall/address list. I cant seem to find or figure out wthat i use to get there current IP address at login
Im guessing I need a global variable to assign the ip to just not sure the cmd to get the ip

#delay script
/delay 10s
:global hotspotip [not sure wht goes here]
/ip firewall address-list add list=LoggedIn address=hotspotip



Thanks
 
electravis
Member Candidate
Member Candidate
Topic Author
Posts: 274
Joined: Tue Jan 26, 2010 12:06 am

Re: running script after hotspot login

Sat Apr 07, 2018 12:34 am

So this is what I came up with but not working

:global username [/ip hotspot active find user=$user];
:global userip [/ip hotspot active get $username address];
/ip firewall address-list add list=LoggedIn address=$userip


Any thoughts
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: running script after hotspot login

Sat Apr 07, 2018 2:59 am

Under IP>Hotspot>User-Profiles, you can set an address-list there and will do what you are scripting.
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: running script after hotspot login

Sat Apr 07, 2018 3:09 am

But to use script:
/ip firewall address-list add list=LoggedIn address=[/ip hotspot active find address]
 
electravis
Member Candidate
Member Candidate
Topic Author
Posts: 274
Joined: Tue Jan 26, 2010 12:06 am

Re: running script after hotspot login

Sat Apr 07, 2018 3:53 am

That first answer is probably perfect but the second will probably help me as well since after they timeout I want to remove them from this list.

Thanks
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: running script after hotspot login

Sat Apr 07, 2018 4:05 am

Under IP>Hotspot>User-Profiles, you can set an address-list there and will do what you are scripting.
With this method the address-list entry will be removed automatically when the user logs out.
 
electravis
Member Candidate
Member Candidate
Topic Author
Posts: 274
Joined: Tue Jan 26, 2010 12:06 am

Re: running script after hotspot login

Mon Apr 09, 2018 7:57 pm

So I have made some progress. I have the on login portion script working how i want it does exactly what I need.

/delay 5s
/ip firewall address-list add list=LoggedIn address=$address comment=$address

However on logout it just deletes all my entries in the address list.
/ip firewall address-list remove [find comment="$address"]

As you can see i was hopping doing a comment would help but no difference.
 
electravis
Member Candidate
Member Candidate
Topic Author
Posts: 274
Joined: Tue Jan 26, 2010 12:06 am

Re: running script after hotspot login

Mon Apr 09, 2018 8:05 pm

Well hit it enough and looks like this did it for meon logout

/ip firewall address-list remove [find comment="$"mac-address""]

Who is online

Users browsing this forum: abdullanetworking, CGGXANNX, Google [Bot], stanisljevic and 81 guests