Picking a DHCP hostname to static DNS script

I wonder how to measure the popularity of various scripts doing the same thing given that one part of users write them themselves (so doesn’t even know some were published) and the other part just takes the first one uncle Google suggests. So you seem to represent the third one who studies the reviews :smiley:

To answer your question, /ip dhcp-server has a parameter lease-script (and, maybe surprisingly, the script is called both when the lease is granted and when it expires, so you have to check the manual to see how to detect at which event the script is called), and /ip dhcp-client has a parameter script (and the script is also called both when the lease is assigned and when it ends).

Compatibility betwen selective DNS forwarding and static DNS records does not depend on the script which copies the hostnames from leases to the static records but on the order of search of the two. As static records are consulted before sending a query outside, it depends on which DNS queries you redirect:

  • if you redirect client’s queries as they enter Mikrotik, they will skip the static records in Mikrotik because they will be forwarded to the external DNS without Mikrotik’s embedded DNS server to even see them
  • if you redirect the query which Mikrotik sends because a client asks for a resolution of something that is not available in the cache of Mikrotik’s embedded DNS cache, the static routes will win

.
Implementing redirection of Mikrotik’s own DNS queries is not exactly simple.