Community discussions

MikroTik App
 
treedark
just joined
Topic Author
Posts: 5
Joined: Fri Nov 05, 2021 12:38 am

Conditions DHCP Leases

Tue Oct 11, 2022 6:02 am

Hello I would like to put atomatic queues on the dhcp server but I would like the reserved ips not to enter the queue list. I tried several combinations of conditions but I couldn't get it to work.

:local queueName "DHCP-$leaseActMAC";
:if ($leaseBound = "1" && (here I wanted the condition if it is dynamic it is true)) do={ /queue simple add name=$queueName target=($leaseActIP . "/32") max-limit=10M/15M comment=[/ip dhcp-server lease get [find where active-mac-address=$leaseActMAC && active-address=$leaseActIP] host-name];
} else={
/queue simple remove $queueName
}


thank you who can help!
Last edited by treedark on Fri Oct 14, 2022 5:19 am, edited 2 times in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Conditions DHCP Leases

Tue Oct 11, 2022 7:23 pm

First, write well the first part:
:local queueName "DHCP-$leaseActMAC"

/queue simple
:if ($leaseBound = "1" and (<condition here that involve $leaseActIP>)) do={
    add name=$queueName target="$leaseActIP/32" max-limit="10M/15M" comment=$"lease-hostname"
} else={
    remove $queueName
}

Second, define better the "reserved IPs" where coming from.
Are already defined in static leases?
 
treedark
just joined
Topic Author
Posts: 5
Joined: Fri Nov 05, 2021 12:38 am

Re: Conditions DHCP Leases

Fri Oct 14, 2022 5:17 am

Hello, thanks for the Extended help, I put one more condition in the code and I managed to get only the ips that are Dynamic to receive the queues follows the code below:
:local queueName "DHCP-$leaseActMAC";
:if ($leaseBound = "1") do={ /queue simple add name=$queueName target=($leaseActIP . "/32") max-limit=15M/15M comment=[/ip dhcp-server lease get [find where active-mac-address=$leaseActMAC && active-address=$leaseActIP && dynamic=yes] host-name];
} else={
     /queue simple remove $queueName
}
I just put the condition of dynamic=yes.

Thanks again!

Who is online

Users browsing this forum: alexantao and 29 guests