M
M
menartIsH2019-03-03 19:55:00
Mikrotik
menartIsH, 2019-03-03 19:55:00

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

2 answer(s)
D
Denis, 2019-03-03
@notwrite

dhcp-client has the ability to fasten the script to trigger. There is an example on wiki.mikrotik.com.

D
Dmitry, 2019-03-06
@hempy80

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];
}

replace the staticIP variable and the interface with your own values, if you have several dhcp clients, change the numbers=0 value to the corresponding one

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question