DHCP Leases to DNS

MikroTik router configured as both DNS & DHCP server.

6 Interfaces (subnets) used, would like to enable computers on different subnets to access eachother on pc-name / pc-name.localdomain.

Way to get DHCP leases to DNS static table? I have tried without any luck. IP addresses works 100%, DNS doesn’t resolve names.

Any help appreciated. Im running v2.9.7

Possible to iterate through all leases to populate in DNS?

I think I’ve asked for this before, but I believe I couldn’t get MT to understand what I was talking about…

many DHCP servers have an option to register the DHCP lease in DNS. I think there is even an official meathod for the DHCP client to request the DNS server register the system in DNS…

MT shuld do this without scripting. We asked it several times, but no help.

As i needed this funcion I just worte a script that does the job:

:set topdomain "yourdomain.com" ; 
/ip dhcp-server lease ;
:foreach i in=[find] \
do={  \
    /ip dhcp-server lease ;
        :if ([:len [get $i host-name]] > 0) do={ \
           :set hostname ([get $i host-name] . "." . $topdomain); \
           :set hostip [get $i address]; \
           :put ( $hostname . " : " . $hostip ) ; \
           /ip dns static ;
           :foreach di in [find] do = { :if ([get $di name] = $hostname) do {/ip dns static remove $di }} 
           /ip dns static add name=$hostname address=$hostip
         }  \
};

Run this in scheduler and it will add static dns entry for each DHCP lease.

could be fine if that could be done on event that lease is assigned.

if logging is enabled, then any lease that gets assignes is logged, so maybe it could be done that way?

just a thought

I agre, and alreadu submited request for developers to add some events so we can attach scripts to be executed when something happens.

Until then, we have to it in hard way, set trigers and repeat scripts inintervals…

After all this DHCP issue shuold be solved by MT itself, without need for such script.