Auto Hotspot Ip Binding and User Creator for by Mac-Login Users
The Script gets the Mac's from dhcp server Lease's
Written by:BrasDeutscher,PA,Brazil
Tested under RouterOS v6.37rc32
{
Enter here the Hotspot responsive Interface bridge, ether etc.
:global hsint "br0"
Enter here the dhcp Server Name
:global sv "hotspot"
###########################
Binding Optionen
:global 1 "regular"
:global 2 "bypassed"
:global 3 "blocked"
###########################
Set here your desired Number 1,2 or 3
:global option $1
Enter here Your User Profile Name
:global prof "2"
Enter here Your User limit-total Byte Value or for 0 leafe it as it is
:global tb "0"
Enter here Your User limit-out Byte Value or for 0 leafe it as it is
:global out "0"
Enter here Your User limit-in Byte Value or for 0 leafe it as it is
:global in "0"
Enter here Your User limit-uptime Value or for 0 leafe it as it is, example: 1d,2d,3d etc....
:global upt "0"
!!-- PLEASE CHANGE NOTHING ON THE FOLLOWING LINES --!!
:global ip
:global ip2
:global mac
:global host
:global new
:global ajust
:global gt
:global gtn
:global user
:global hs [/ip hotspot get [find where interface="$hsint" ] name ];
:global date [/system clock get date ]
:foreach d in=[/ip dhcp-server lease find where server="$sv" ! dynamic ! disabled ! block-access ] do={
:set ip [/ip dhcp-server lease get $d address ];
:set mac [/ip dhcp-server lease get $d mac-address ];
:set host [/ip dhcp-server lease get $d host-name ];
:if ([/ip hotspot ip-binding find where mac-address=$mac ] = "" ) do={
:set new [/ip hotspot ip-binding add mac-address=$mac address=$ip to-address=$ip server="$hs"
type=$option comment="$host" ];
:log warning ("New Binding Mac-$mac IP-$ip Host--$host Type ist $option");
} else={
:if ([/ip hotspot ip-binding find where mac-address=$mac address=$ip to-address=$ip ] = "" ) do={
:set ip2 [/ip hotspot ip-binding get [find where mac-address=$mac ] address ];
:set ajust [/ip hotspot ip-binding set [find where mac-address=$mac ] address=$ip to-address=$ip
type=$option comment="$host" ];
:log warning ("Binding change $mac from $ip2 to $ip Host= $host Type to $option");
#######################################################################################################
!!-- To enable the Auto by mac-login User Creator Remove the # Sign's em front of the Script Lines --??
!!-- User Creator Tool set's Mac as user name,mac-address and Password --!!
!!-- By this Setup User is not required to use the http Login Page, it's auto Login --!!
} else={
:if ([/ip hotspot ip-binding find where mac-address=$mac ] != "" ) do={
:global gt [/ip hotspot ip-binding get [find where mac-address=$mac ] type ];
:global gtn [:len "$gt" ];
:if ("$gtn" = "0" ) do={
:if ([/ip hotspot user find where mac-address=$mac ! default ! disabled ! dynamic ] = "" ) do={
:set user [/ip hotspot user add name=$mac server="$hs" mac-address=$mac password=$mac \
profile="$prof" limit-bytes-total="$tb" limit-uptime="$upt" limit-bytes-out="$out" \
limit-bytes-in="$in" comment="" ];
:log warning ("New hs User Name,Mac => $mac Server => $hs");
:log warning ("Profil=$prof Uptime-Limit=$upt");
}}}}}}}