Hello, everybody. I'm trying to block unwanted dhcp client connections. I wouldn't use firewall because there are already a lot of rules. I'm trying this way but if I simply block an ip address it will have connectivity until server renews the lease. So I should disable and enable again the number to cut off that ip address.
But there's no way to make it work.
Thanks.
:local newDynamics value=[/ip dhcp-server lease find dynamic=yes];
:local newList value="";
:foreach i in=[$newDynamics] do={
:local dynamicIP [/ip dhcp-server lease get $i address];
:local dynamicMAC [/ip dhcp-server lease get $i mac-address];
:local dynamicHOST [/ip dhcp-server lease get $i host-name];
:local dynamicNUMBER [/ip dhcp-server lease get $i number];
:set $newList value=($newList."Assigned IP address: ".$dynamicIP."\r\n"."MAC Address: ".$dynamicMAC."\r\n"."Hostname: ".$dynamicHOST."\r\n"."IP Made Static."."\r\n"."______________________________________________________________________________"."\r\n"."\r\n");
/ip dhcp-server lease make-static [/ip dhcp-server lease find mac-address=$dynamicMAC];
:delay 2s;
/ip dhcp-server lease set block-access=yes [/ip dhcp-server lease find address=$dynamicIP];
:delay 2s;
/ip dhcp-server lease disable numbers=[/ip dhcp-server lease find number=$dynamicNUMBER];
:delay 2s;
/ip dhcp-server lease enable numbers=[/ip dhcp-server lease find number=$dynamicNUMBER];
};