Mikrotik Hotspot Data Limit Trial
Mikrotik Hotspot Data Limit Trial
Mikrotik's hotspot service is quite amazing considering what it costs. It does have some limitations though. One of these is the fact that you cannot set a data limit to the trial account, only a time limit.
Luckily there are a few workarounds for this, the original concept for this comes from www.mikrotik-routeros.com but I have corrected a couple of bugs and added some functionality.
Start by creating your FreeUser profile:
IP>HOTSPOT>USER PROFILES>ADD
Name: FreeUser
You can customize this as you like, my preference is to only allocate 512k of bandwidth to the free users
Create the following two scripts on your routerboard by going to SYSTEM>SCRIPTS>ADD
Script 1:
The first script is the one that checks if a user has reached your specified limit, you can change the limit in the second line of the script.
Name: limitdata
Script 2:
The second script resets the counters of all free users so that they can receive a new allocation.
Name: clearusers
You then need to add two scheduled tasks under SYSTEM>SCHEDULER:
The first task will determine how often a specific mac address' usage is reset. I run it at midnight every day, which means that in my example people can use 50MB per day for free.
The second task will determine how often the system will check if a user has reached the quota. I run it every ten seconds, but on a busy routerboard you may have to set this to a higher value:
You should now be able to have users use the predefined trial without needing a login. Just remember to enable to trial option for your hotspot.
Luckily there are a few workarounds for this, the original concept for this comes from www.mikrotik-routeros.com but I have corrected a couple of bugs and added some functionality.
Start by creating your FreeUser profile:
IP>HOTSPOT>USER PROFILES>ADD
Name: FreeUser
You can customize this as you like, my preference is to only allocate 512k of bandwidth to the free users
Create the following two scripts on your routerboard by going to SYSTEM>SCRIPTS>ADD
Script 1:
The first script is the one that checks if a user has reached your specified limit, you can change the limit in the second line of the script.
Name: limitdata
#Set your dowload limit in MegaBYTES!
:local downloadlimitmb "50"
### You will not need to edit anything below this line ###
:local downloadlimit [($downloadlimitmb * 1048576)]
:local counter
:local datadown
:local username
:local macaddress
:foreach counter in=[/ip hotspot active find where user~"^[T][-].{17}"] do={
:set datadown [/ip hotspot active get $counter bytes-out]
:if ($datadown>$downloadlimit) do={
:set username [/ip hotspot active get $counter user]
:set macaddress [/ip hotspot active get $counter mac-address]
/ip hotspot user remove [/ip hotspot user find where name=$username profile=FreeUser]
/ip hotspot user add name=$username limit-bytes-out=$downloadlimit mac-address=$macaddress profile=FreeUser
/ip hotspot active remove $counter
:log info "Force logout on user: $username - Reached download quota"
}}
:local downloadlimitmb "50"
### You will not need to edit anything below this line ###
:local downloadlimit [($downloadlimitmb * 1048576)]
:local counter
:local datadown
:local username
:local macaddress
:foreach counter in=[/ip hotspot active find where user~"^[T][-].{17}"] do={
:set datadown [/ip hotspot active get $counter bytes-out]
:if ($datadown>$downloadlimit) do={
:set username [/ip hotspot active get $counter user]
:set macaddress [/ip hotspot active get $counter mac-address]
/ip hotspot user remove [/ip hotspot user find where name=$username profile=FreeUser]
/ip hotspot user add name=$username limit-bytes-out=$downloadlimit mac-address=$macaddress profile=FreeUser
/ip hotspot active remove $counter
:log info "Force logout on user: $username - Reached download quota"
}}
Script 2:
The second script resets the counters of all free users so that they can receive a new allocation.
Name: clearusers
:log info "Checking Users"
:local counter
:foreach counter in=[/ip hotspot user find profile="FreeUser" ] do={
/ip hotspot user remove $counter
}
:local counter
:foreach counter in=[/ip hotspot user find profile="FreeUser" ] do={
/ip hotspot user remove $counter
}
You then need to add two scheduled tasks under SYSTEM>SCHEDULER:
The first task will determine how often a specific mac address' usage is reset. I run it at midnight every day, which means that in my example people can use 50MB per day for free.
add disabled=no interval=1d name=ClearUsers on-event=clearusers policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=jan/01/2002 start-time=00:00:01
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=jan/01/2002 start-time=00:00:01
The second task will determine how often the system will check if a user has reached the quota. I run it every ten seconds, but on a busy routerboard you may have to set this to a higher value:
add disabled=no interval=10s name=DataLimit on-event=limitdata policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=oct/07/2013 start-time=00:00:00
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
start-date=oct/07/2013 start-time=00:00:00
You should now be able to have users use the predefined trial without needing a login. Just remember to enable to trial option for your hotspot.
Comments
I'm selling fresh & genuine SSN Leads, with good connectivity. All data are tested & verified.
Headers in Leads:
First Name | Last Name | SSN | Dob | Address | State | City | Zip | Phone Number | Account Number | Bank NAME | DL Number | House Owner
*You can ask for sample before any deal
*Each SSN lead will be cost $1
*Premium Lead will be cost $5
*If anyone wants in bulk I will negotiate
*Sampling is just for serious buyers
Hope for the long term deal
For detailed information please contact me on:
Whatsapp > +923172721122
Email > leads.sellers1212@gmail.com
Telegram > @leadsupplier
ICQ > 752822040