Caps-Man auto access-list getting mac from dhcp-lease

Caps-Man Automatic access-list

Written by:BrasDeutscher,PA,Brazil

Works on RouterOS v6.37rc27

!!-- Static Hotspot users get permission to use all Caps --!!

!!-- Important, you have to set the Load Balancing Group on each Cap --!!

!!-- Script Load-Balancing-Group Number for Dynamic Hotspot Users is “2” --!!

{

Set the signal strength of reception here - listening number is weaker signal

Options= -80..80 -70..70 -60..60 , copy and paste from here

:global rg “-60..60”

Set the Hotspot Server Name here

:global sv “1”

\

!!-- PLEASE CHANGE NOTHING MORE BELOW --!!

:global mac1
:global all
:global date [/system clock get date ]
:foreach i in=[/ip hotspot user find where server=“$sv” ! default ! dynamic ! disabled ] do={
:set mac1 [/ip hotspot user get $i mac-address ];
:if ([/caps-man access-list find where mac-address=$mac1 (comment~“/”) ] = “” ) do={
:set all [/caps-man access-list add mac-address=$mac1 interface=all signal-range=“$rg” ssid-regexp=“”
action=accept comment=“$date” ];
:log warning (“ACL for Static Hotspot User $mac1 and all Caps”);
}}
:global usr
:global mac2
:global ip
:foreach j in=[/ip hotspot active find where server=“$sv” (user~“T-”) ] do={
:set usr [/ip hotspot active get $j user ];
:set ip [/ip hotspot active get $j address ];
:set mac2 [:pick $usr 2 19 ];
}
:global int
:global lg
:global add
:foreach k in=[/caps-man interface find where ! dynamic ! disabled ] do={
:set lg [/caps-man interface get $k configuration.load-balancing-group ];
:if (“$lg” = 2 ) do={
:set int [/caps-man interface get $k name ];
:if ([/caps-man access-list find where mac-address=$mac2 interface=“$int” comment=$ip ] = “” ) do={
:set add [/caps-man access-list add action=accept mac-address=$mac2 interface=“$int”
signal-range=“$rg” comment=$ip ];
:log warning (“New ACL for $usr created “);
} else={
:global mac3
:global lim
:global upt
:global user
:global clear
:foreach x in=[/ip hotspot user find where ! default dynamic ] do={
:set lim [/ip hotspot user get $x limit-uptime ];
:set upt [/ip hotspot user get $x uptime ];
:if ($lim <= $upt ) do={
:set user [/ip hotspot user get $x name ];
:set mac3 [/ip hotspot user get $x mac-address ];
:log warning (“ACL for $user and Cap-$int Removed”);
:set clear [/caps-man access-list remove [find where mac-address=$mac3 interface=”$int” ]];
}}}}}}
CapsMan ACL1.png
CapsManACL2.png