Month: July 2015

Mikrotik Hotspot IP & Mac Binding


Updated on 25/07/2015
Below script find active user on hotspot and set static ip with mac binding into 2 section.

section 1 find all active users on hotspot
section 2 find IP & Mac into DHCP-Server Leases.

How its works ?
copy below code into system script with name hotspot-binding.
create schedule for 10min timming to run this code ..

hotspot-binding-script

hotspot-binding-schedule

:foreach h in=[/ip hotspot active find] do={
:global address [/ ip hotspot active get $h address];
:global user [/ip hotspot active get $h user];
:global mac [/ip hotspot active get $h mac-address];
/ip hotspot user set $user  mac=$mac address=$address;
:foreach x in=[/ip dhcp-server lease find] do={/ip dhcp-server lease make-static $x};
}

ROS Code Terminal Export for version 6.x :

/system script
add name=hotspot-binding policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive source=":foreach \
    h in=[/ip hotspot active find] do={\r\
    \n:global address [/ ip hotspot active get \$h address];\r\
    \n:global user [/ip hotspot active get \$h user];\r\
    \n:global mac [/ip hotspot active get \$h mac-address];\r\
    \n/ip hotspot user set \$user  mac=\$mac address=\$address;\r\
    \n:foreach x in=[/ip dhcp-server lease find] do={/ip dhcp-server lease make-\
    static \$x};\r\
    \n}"
/system scheduler
add disabled=no interval=10m name=binding-hotspot on-event=hotspot-binding \
    policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
    start-date=jul/24/2015 start-time=22:10:03

ROS Code Terminal Export for version 5.x :


/system script
add name=hotspot-binding policy=\
    ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
    source=":foreach h in=[/ip hotspot active find] do={\r\
    \n:global address [/ ip hotspot active get \$h address];\r\
    \n:global user [/ip hotspot active get \$h user];\r\
    \n:global mac [/ip hotspot active get \$h mac-address];\r\
    \n/ip hotspot user set \$user  mac=\$mac address=\$address;\r\
    \n:foreach x in=[/ip dhcp-server lease find] do={/ip dhcp-server lease make-\
    static \$x};\r\
    \n}"

/system scheduler
add disabled=no interval=10m name=binding-hotspot on-event=hotspot-bind
    policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
    start-date=jul/24/2015 start-time=22:10:03

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

Script- DHCP Lease to Simple Queues


dhcp_server

dhcp_server_lease_script

simple_queue

#Lease to Simple Queues
#V.1 By Virtual IT Export

:local queueName "Client- $leaseActMAC";

:if ($leaseBound = "1") do={
    /queue simple add name=$queueName target=($leaseActIP . "/32") limit-at=1024k/1024k max-limit=1024k/1024k comment=[/ip dhcp-server lease get [find where active-mac-address=$leaseActMAC && active-address=$leaseActIP] host-name];
} else={
    /queue simple remove $queueName
}

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group