Community discussions

MikroTik App
 
fbuster
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Sat May 02, 2015 12:52 pm
Location: BE

Remove reserved leases from the same device

Sat Mar 03, 2018 11:57 am

There is a device on our network that requests dhcp leases frequently with a new mac address
resulting in a big list of reserved leases from the same android machine.

My idea is to search for the mac address that starts with xx:xx:xx because it is unique to our network but always
the same for that device.

And then deleting all the reserved leases from it every hour or so.

I just need to add some code to the script below to only delete leases with starting mac of xx:xx:xx
/system scheduler
add interval=1d name=delete-dhcp-leases on-event="/ip dhcp-server lease remove [find dynamic]" policy=read,write start-date=jun/02/2017 start-time=00:00:00
Can anyone help?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10544
Joined: Mon Jun 08, 2015 12:09 pm

Re: Remove reserved leases from the same device  [SOLVED]

Sat Mar 03, 2018 1:02 pm

You could use something like this:

/ip dhcp-server lease remove [find dynamic and mac-address~"^DA:A1:19:"]
 
fbuster
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Sat May 02, 2015 12:52 pm
Location: BE

Re: Remove reserved leases from the same device

Sat Mar 03, 2018 2:31 pm

Thank you, I tried testing it in a terminal first before scheduling it, but it doesnt show the lease.
Might i be doing something wrong? I used the command below :
[rb951@MikroTik] /ip dhcp-server lease> :put [find mac-address~"^60:01:94"]        
*756;*757
 
pe1chl
Forum Guru
Forum Guru
Posts: 10544
Joined: Mon Jun 08, 2015 12:09 pm

Re: Remove reserved leases from the same device

Sat Mar 03, 2018 2:34 pm

It works but it does not print the lease details but the lease numbers when you use it that way.
Those numbers are OK as a parameter to "remove".

/ip dhcp-server lease print where mac-address~"^60:01:94"
 
fbuster
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Sat May 02, 2015 12:52 pm
Location: BE

Re: Remove reserved leases from the same device

Sat Mar 03, 2018 2:36 pm

:-)