Community discussions

MikroTik App
 
User avatar
KatsuroKurosaki
just joined
Topic Author
Posts: 18
Joined: Tue Jul 24, 2012 10:53 am
Contact:

HotSpot, When Simultaneous-Use reached, kick previous user.

Thu Aug 02, 2012 11:39 am

Good day everyone,

I would like to thank all Mikrotik developers the great devices they are doing (even RouterBOARDs, RouterOS,...), we are very happy in our company to use them :D

At this point, we are wondering, if possible from Mikrotik or our RADIUS Server ( If someone wondering, it's FreeRADIUS, but I'm not asking about Fr here :P ) to kick users when they reach Simultaneous-Use attribute.
For example: a Simultaneous-Use of 3, will allow 3 simultaneous use of the same username/password, and if a 4th logs-in, it will message the user that Simultaneous-Use has been reached.. My question is about if possible to kick the 1st user that logged-in, and the 4th user allow access to Internet.
Someone wondering about Simultaneous-Use = 1? Yes, One user will log-in, and a new one will log-out the previous user and log-in the new user.

Thanks for your help, :D
 
renee
just joined
Posts: 1
Joined: Fri Oct 04, 2013 3:39 pm

Re: HotSpot, When Simultaneous-Use reached, kick previous us

Fri Oct 04, 2013 4:02 pm

Hi!

I'm not a big Mikrotik user, but my problem was also some days earlier, so I made a small srcipt in the Hotspot/User-Profiles/default On-login srcipt.
:local uname $user;
:local usercount 0;
:local usertime "00:00:00";
:local kickable;
:local maxuser 2;

:foreach i in=[/ip hotspot active find user=$uname] do= {
  :local curup [/ip hotspot active get $i uptime];
  :if ( $curup > $usertime ) do={
        :set usertime $curup; 
        :set kickable $i;
   }
  :set usercount ($usercount+1);
}
:if ($usercount >= $maxuser) do={
  :log info "Login user: $uname ($usercount/$maxuser) - Oldest $usertime will be logout!";
  /ip hotspot active remove numbers=$kickable;
} else {
   :log info "Login user: $uname ($usercount/$maxuser)";
}
At maxuser you can set, how many simultaneous connection can be. If it is full, then kick the oldest, and leave one place for the new login. Example: If it set to 2, then if you login as second, then the first will be kicked out, because you need one place for the next login. If it set 4 and you login as 4th, then the first will be kicked out. It choose always the oldest uptime...
Be careful with the cookies. If it's enable, should be on the status page the refreshment rate set to more rarely. Example: If you log in with the laptop, and the status page is working with a refreshment 1 minute, and you are log in with your smartphone, it will be kicked the laptop out, but when the laptop refresh the status page in the background - and log in with cookie -, it will be kick your smartphone out. So I have set the cookies but with status refreshment is 10 minutes...
 
bluelu6
just joined
Posts: 2
Joined: Tue Nov 29, 2016 8:16 pm

Re: HotSpot, When Simultaneous-Use reached, kick previous user.

Tue Nov 29, 2016 8:22 pm

Hello everybody!

Thank you very much renee for this perfect solution. I've had the same problem then katsurokurosaki had and been searching for months to find this solution!
I've entered the script within the winbox Hotspot settings and now it finally works that I can auto logout another user when a new user is entering the wifi code.

However, I still have a problem, that the tickets generated within the Mikrotik Usermanager are not affectet by this script.
Can you tell me how i can enter this script to affect also the users which are generated and handled within the usermanager?

Thank you very much for your help!!

Have a nice evening.
 
taknamecom
just joined
Posts: 15
Joined: Thu Nov 13, 2014 2:09 pm

Re: HotSpot, When Simultaneous-Use reached, kick previous user.

Wed Mar 01, 2017 9:06 am

Hello everyone.
I need this script. and I added this script to log on section.
but not working.
anybody have another script/solution ?
thanks.