Comments on Don’t use RouterOS DHCP lease scripts to manage DNS

Be civil and read the entire article first. This is not a support forum. Comments from new contributors are moderated. English only.

Leave a comment

Required. Optional. E.g. your homepage, Twitter. or Email required unless anonymous. Not published or shared. Reuse to be recognized as the same commenter.
Plain-text only. Begin lines with a > character to quote.

Jan

Hi,

using your script for a while now, runs quite well.

But my log is flooded with entrys like

"static dns entry changed by xxx"

any way to run the script without entrys to the log?

Those are system-generated log messages. RouterOS doesn’t provide any flags to quiet them or any options to silence one script. You’ve got four options: 1) Disable logging system-wide, 2) Disable logging at the beginning and re-enable it at the end of the script (you might lose other messages), 3) Stop using the script, or 4) Ignore the log messages.

Xecuter2

Love the script but wondering if there is a way to make it not write to flash for every update if changes are not detected? I lowered the run time down to every hour for now but it would be amazing if there was an easy way to have it check for duplicates/same data before pushing the writes(or maybe it does this and there are still a lot?). Thank you!

Xecuter2, sure. You’d need a second conditional before line 22. Something like this:

> ([:len [/ip dns static find where name=$regdomain address!=$hostaddr comment=$magiccomment]] = 0)

It could be done more efficiently by storing a reference to the first lookup and then checking its address. I might update the script to do this in the future.

Xecuter2

This worked a charm, thank you again. I set to 1 minute and writes do not increase at all now unless something changes. I know it probably doesn't matter much with how many writes the flash can take but less seems better. I noticed that the DHCP lease store to disk also must check for past entries as it does not write unless something changes.

There are lots of scripts out there; this one is simple, easy to read, and does the job. Thanks :)

Good post. You are right about renewals. However I want to suggest you try using both the lease script trigger AND a scheduled trigger. You can have it scheduled less frequently if you want since the trigger based one will cover most of the cases (without latency).