Hotspot trial Option for new Mkt Mac Auth Mode -> Mac as Username and Password
Script for Latest RouterOS v.6.33rc37
{
set your DHCP Server here
:global sv "dhcp1";
:foreach i in=[/ip dhcp-server lease find where server=$sv dynamic=yes ] do={
/ip dhcp-server lease make-static [ find ];
}
}
{
set your DHCP Server here
:global sv "dhcp1";
set your hotspot route and server address here # # the allowed format is example "192.168.0.0/26 192.168.0.63"
To Work you must use the Broadcast address which from your Network
:global route "192.168.0.0/26 192.168.0.63";
set the Name from your Interface Wireless here
:global wif "wlan";
:foreach i in=[/ip dhcp-server lease find where server=$sv dynamic=no ] do={
:local ip [/ip dhcp-server lease get $i address ];
:local mac [/ip dhcp-server lease get $i mac-address ];
:local date [/system clock get date ];
:if ([/ip dhcp-server lease find comment=$mac ] = "" ) do={
/ip dhcp-server lease set [ find address=$ip ] client-id="1:$mac" use-src-mac=yes server=$sv lease-time=10m comment="$mac";
set your up and download Limit in Mib here
:local in "25"
:local out "50"
set your hotspot-server Name here
:local hss "hotspot";
set your hotspot-user Profile Name here # # ! First you must create this Profile in -> hotspot-user-profile
:local hup "9-Test";
set your desired up/download Bandwidth here
:local band "40k/80k"
set max uptime days here
:local days "1"
do not edit the following
:local upload [($in10241024)];
:local download [($out10241024)];
:local up [($days*86400)];
/ip hotspot user profile set [ find name="$hup" ] rate-limit="$band";
:if ([ /ip hotspot user find name="$mac" ] = "" ) do={
/ip hotspot user add server=$hss profile="$hup" name="$mac" address=$ip mac-address=$mac
password=$mac routes="$route" limit-bytes-in=$upload limit-bytes-out=$download limit-uptime=$up comment="$date";
/ip hotspot ip-binding add mac-address=$mac address=$ip to-address=$ip server=$hss
type=regular comment="$mac";
:if ([/interface wireless access-list find mac-address=$mac ] = "" ) do={
/interface wireless access-list add interface="$wif" mac-address=$mac comment="$ip"
}
}
}
}
}
![]()
\
Auto Remove from Trial User after your defined Time
This Script Removes hotspot user, ip-binding, dhcp-server lease and wireless access-list entry
Script for RouterOS v.6.33rc37
add this script to scheduler and run with Interval of 12 hours
{
set how much days here
:local offset 1
:global today
set the Trial user user-profile Name here
:global hup "9-Test";
set your DHCP Server Name here
:global dhcp "dhcp1";
set your Hotspot Server Name here
:global hsn "hotspot";
set your Wireless Interface Name here
:global wif "wlan";
{
:local date [ /system clock get date ]
:local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" )
:local monthdays ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 )
:local days [ :pick $date 4 6 ]
:local monthtxt [ :pick $date 0 3 ]
:local year [ :pick $date 7 11 ]
:local months ([ :find $montharray $monthtxt] )
:for nodays from=0 to=[:tonum $months] do={
:set days ( $days + [ :pick $monthdays $nodays ] )
}
:set days ($days + $year * 365)
:set today $days
}
:foreach i in [ /ip hotspot user find where profile="$hup" ] do={
:if ([ :find [ /ip hotspot user get $i comment ] ] = 0 ) do={
:local date [ /ip hotspot user get $i comment ]
:local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" )
:local monthdays ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 )
:local days [ :pick $date 4 6 ]
:local monthtxt [ :pick $date 0 3 ]
:local year [ :pick $date 7 11 ]
:local months ( [ :find $montharray $monthtxt ] )
:for nodays from=0 to=[:tonum $months] do={
:set days ( $days + [ :pick $monthdays $nodays ] )
}
:set days ($days + $year * 365)
:if ( ($days + $offset) < $today ) do={
:local name [/ip hotspot user get $i name]
:log info "HOTSPOT EXPIRE SCRIPT: Removing Hotspot user $name first logged in $date"
[ /ip hotspot user remove $i ]
[ /ip hotspot active remove [ find where user=$user ] ]
[ /ip dhcp-server lease remove [ find where server="$dhcp" comment=$name ] ]
[ /ip hotspot ip-binding remove [ find where server="$hsn" comment=$name ] ]
[ /interface wireless access-list remove [ find where interface="$wif" mac-address=$name ] ]
}
}
}
}
![]()
My Log entrys after running the Script
12:28:25 wireless,info 30:76:6F:E3:B0:7F@wlan: connected
12:28:34 dhcp,info dhcp1 deassigned 10.63.241.227 from 30:76:6F:E3:B0:7F
12:28:34 system,info dhcp lease changed by ersitizastes
12:28:34 system,info hotspot user 30:76:6F:E3:B0:7F added by ersitizastes
12:28:34 system,info hotspot ip binding rule added by ersitizastes
12:28:34 wireless,info 30:76:6F:E3:B0:7F@wlan: disconnected, access-list changed
12:28:34 system,info wireless access-list entry added by ersitizastes
12:28:35 wireless,info 30:76:6F:E3:B0:7F@wlan: connected
12:28:40 dhcp,info dhcp1 assigned 10.63.241.227 to 30:76:6F:E3:B0:7F
12:28:40 hotspot,info,debug 30:76:6F:E3:B0:7F (10.63.241.227): trying to log in by mac
12:28:40 hotspot,account,info,debug 30:76:6F:E3:B0:7F (10.63.241.227): logged in