Community discussions

MikroTik App
 
SapieH
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Wed May 13, 2009 9:44 pm

IP exclusion in script

Fri Nov 01, 2019 4:44 pm

I am using the following script to control individual devices in a coffee shop (free Wi-Fi). I have to exclude certain devices from being affected by this script. How do I go about doing this?


:local queueName "Client- $leaseActMAC";

:if ($leaseBound = "1") do={
/queue simple add name=$queueName target=($leaseActIP . "/32") parent="Internal" max-limit=1000k/1000k comment=[/ip dhcp-server lease get [find where active-mac-address=$leaseActMAC && active-address=$leaseActIP] host-name];
} else={
/queue simple remove $queueName
}
 
User avatar
tomaskir
Trainer
Trainer
Posts: 1162
Joined: Sat Sep 24, 2011 2:32 pm
Location: Slovakia

Re: IP exclusion in script

Fri Nov 01, 2019 10:30 pm

Your post is rather vague on the details, but something like this should do:
/ip dhcp-server lease
:foreach i in=[find dynamic] do={
  :local mac [get $i active-mac-address]
  :local ip [get $i active-address]
  :local host [get $i host-name]

  /queue simple
  add name=("Client-" . $mac) target=($ip . "/32") parent="Internal" max-limit=1000k/1000k comment=$host
}
 
SapieH
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Wed May 13, 2009 9:44 pm

Re: IP exclusion in script

Sat Nov 02, 2019 9:44 am

Thanks for that. Much appreciated.