Answer the question
In order to leave comments, you need to log in
How to write script for mikrotik hap ac lite?
Hello!
I received a static ip address from the operator. Once a week, the lease expires and the dhcp server does not renew the address, it issues a new one. Accordingly, all connections are torn and the Internet is falling. How can I write a script on the event
dhcp-client on ether1 lost IP address --.--.--.-- - received NAK from dhcp server 0.0.0.0
checked which address on the interface and if it does not match, then release / renew.
Well, or to check every 5 minutes and if it doesn’t match, then release / renew.
Thanks in advance for any help!
Answer the question
In order to leave comments, you need to log in
dhcp-client has the ability to fasten the script to trigger. There is an example on wiki.mikrotik.com.
in the dhcp-client settings in the Advanced tab add the script
:local staticIP 192.168.1.182/24;
:local newIP [/ip address get [find interface="ether1"] address];
:if ($newIP != $staticIP) do={
:delay 5;
:log info "trying to change $newIP to $staticIP";
[/ip dhcp-client release numbers=0];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question