Autonomous Queue Creation For DHCP Server Leases

Creating speed limits for devices is a common practice for Mikrotik users. This can be a very time-consuming task when you are dealing with multiple DHCP servers and massive subnets. We have created a Script run in 2-minute intervals to check for new and expired DHCP leases and generate a queue for each DHCP Server Lease present on your RouterOS device.

/system scheduler
add interval=2m name=”Qeueu Leases” on-event=”/ip dhcp-server lease {\r\
\n :foreach i in=[find] do={\r\
\n :local leasedIp [get \$i address]\r\
\n /queue simple {\r\
\n :if ([:len [find target=(\”\$leasedIp/32\”)]] = 0) do={\r\
\n add name=\$leasedIp target=\$leasedIp queue=default/defaul\
t max-limit=3M/6M \r\
\n }\r\
\n }\r\
\n }\r\
\n}\r\
\n/queue simple {\r\
\n :if (\$leaseBound = \”1\”) do={\r\
\n\t add name=\$leaseActIP target=\$leasedIp queue=default/default max-li\
mit=3M/6M \r\
\n } else={\r\
\n remove [find name=\$leaseActIP]\r\
\n }\r\
\n}” policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-time=startup

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply