Page 1 of 1

DHCP Leases to DNS

Posted: Wed Jul 26, 2006 2:12 pm
by MikroManagement
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

Posted: Thu Jul 27, 2006 7:05 pm
by MikroManagement
Possible to iterate through all leases to populate in DNS?

Posted: Fri Jul 28, 2006 12:52 am
by Hammy
I think I've asked for this before, but I believe I couldn't get MT to understand what I was talking about...

Posted: Thu Aug 03, 2006 4:37 pm
by BrianHiggins
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...

Posted: Fri Aug 04, 2006 9:45 am
by pedja
MT shuld do this without scripting. We asked it several times, but no help.

Posted: Wed Sep 20, 2006 3:38 pm
by pedja
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.

Posted: Wed Sep 20, 2006 4:09 pm
by janisk
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

Posted: Wed Sep 20, 2006 4:25 pm
by pedja
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.