This script works fine in version 2.9.11 , but is not working in version 3.2 and 4.5.Any help please?What we need to do?
\
find static IP version 8
:log info (“!!! SYS UPTIME (-” . [/ip address get [/ip address find interface=wlan1] address] . "-) → " . [/system resource get uptime]);
:set countusers 0;
:foreach k in [/ip arp find interface=ether1] do={:set countusers ($countusers + 1); /ip arp remove $k;}
:log info ("!!! USERS ONLINE → " . $countusers);
:delay(60);
:foreach i in [/ip arp find interface=ether1] do={
:set arpip [/ip arp get $i address];
:set arpmac [/ip arp get $i mac-address];
:set notstatic 0;
:foreach j in [/ip dhcp-server lease find] do={
:set dhcpip [/ip dhcp-server lease get $j address];
:if ( ($dhcpip=$arpip) ) do={:set notstatic ($notstatic +1);}
list of acceptable ip. Separate with ||
:if ( $arpip=10.207.100.1 || $arpip=10.207.1.1 || $arpip=10.207.1.2 || $arpip=10.207.1.3 || $arpip=10.207.1.7 || $arpip=10.207.100.2 || $arpip=10.207.100.3 || $arpip=10.207.100.4 || $arpip=10.207.100.5 || $arpip=10.207.100.7) do={:set notstatic ($notstatic +1);}
}
:if ($notstatic =0) do {
:log info (“!!! STATIC IP → " . $arpip . " mac " . $arpmac . " waiting 100 seconds to confirm.”);
:delay(100);
:set notstatic 0;
:foreach j in [/ip dhcp-server lease find] do={
:set dhcpip [/ip dhcp-server lease get $j address];
:if ( ($dhcpip=$arpip) ) do={:set notstatic ($notstatic +1);}
list of acceptable ip. Separate with ||
:if ( $arpip=10.207.100.1 || $arpip=10.207.1.1 || $arpip=10.207.1.2 || $arpip=10.207.1.3 || $arpip=10.207.1.7 || $arpip=10.207.100.2 || $arpip=10.207.100.3 || $arpip=10.207.100.4 || $arpip=10.207.100.5 || $arpip=10.207.100.7) do={:set notstatic ($notstatic +1);}
}
}
:set isinfirewall 0;
:if ($notstatic =0) do {
:log info ("!!! STATIC IP → " . $arpip . " mac " . $arpmac );
:foreach m in [/ip firewall filter find comment=("Blocked Mac " . $arpmac . " of Static IP " . $arpip)] do={:set isinfirewall 1};
:if ($isinfirewall =0) do={
/ip firewall filter add chain=forward src-mac-address=$arpmac action=drop comment=(“Blocked Mac " . $arpmac . " of Static IP " . $arpip);
:log info (”!!! STATIC IP → " . $arpip . " mac " . $arpmac . " → BLOCKED");
} else={
:log info (“!!! STATIC IP → " . $arpip . " mac " . $arpmac . " → Already Blocked”);
};
}
}