Page 1 of 1

Diabling a DHCP server

Posted: Sun Feb 09, 2020 4:34 pm
by bigd35
Hi, I'm still quite new to RouterOS's scripting, can anyone perhaps help to say how I would disable an DHCP server in a script?

Re: Diabling a DHCP server

Posted: Mon Feb 10, 2020 6:35 pm
by Zacharias
What ? Simply do not configure a DHCP Server...

Re: Diabling a DHCP server

Posted: Tue Feb 11, 2020 1:15 am
by inteq
To disable
/ip dhcp-server disable 0
To enable
/ip dhcp-server enable 0
If you have multiple DHCP servers, use /ip dhcp-server print to find the number corresponding to your server.

Re: Diabling a DHCP server

Posted: Thu Feb 13, 2020 9:45 am
by eworm
Do not follow that advise! You should never use numerical index in scripts.
Try something like:
/ip dhcp-server disable [ find where comment=.... ]
Change the find to your needs.

Re: Diabling a DHCP server

Posted: Thu Feb 13, 2020 1:31 pm
by inteq
You should never use numerical index in scripts.
Any particular reason?

Re: Diabling a DHCP server

Posted: Thu Feb 13, 2020 3:23 pm
by nescafe2002
https://wiki.mikrotik.com/wiki/Manual:S ... ter_values

But for most entries with a identifier, you can use the name instead:

/ip dhcp-server disable default
/ip dhcp-server enable default

Re: Diabling a DHCP server

Posted: Thu Feb 13, 2020 5:08 pm
by inteq
https://wiki.mikrotik.com/wiki/Manual:S ... ter_values

But for most entries with a identifier, you can use the name instead:

/ip dhcp-server disable default
/ip dhcp-server enable default
Thank you. Good info.

Re: Disabling a DHCP server leases static ip

Posted: Tue Jun 08, 2021 2:51 pm
by cyberjhep
Hello need help about this script tha goal is under dhcp server leases fine a comment who -1 and do action then disable.

for x from=0 to=70 do={
/ip dhcp-server leases [find comment=$x] comment=($x-1)
delay 50ms
}

:foreach i in=[/ip dhcp-server leases find] do={
:local address [/ip dchp-server leases set value=0];
:local comment /ip dchp-server leasest get $i comment];
if ($comment=-1) do={
/ip dchp-server leases disable [find where name=$uname]
}
}

Re: Diabling a DHCP server

Posted: Tue Jun 08, 2021 7:10 pm
by rextended
I DO NOT UNDERSTAND ANYTHING!
WHAT DO YOU WANT TO DO? (ignoring script)