Can the DNS client look at DHCP leases?

In our transition from a Linux-based router running, among other things, dnsmasq, one piece of functionality we are not seeing is for the DNS proxy/cache in RouterOS to look at the DHCP leases for an IP address. We used this so backup serves, for example, could reference internal, DHCP configured hosts. Another use: admin’ing internal machines without having to look at the least table first.

Is there anyway to get RouterOS to respond with the IP of a machine that has a DHCP lease when I query it with, say,

name-of-internal-machine.our-domain.com?

Thanks!

There’s a wiki entry here:
http://wiki.mikrotik.com/wiki/Setting_static_DNS_record_for_each_DHCP_lease

Basically, it creates DNS static entries for each DHCP lease entry obtained that has a hostname.

I’ve been using a script based from this for some time now, and it works great!

Thanks! A little hackish, but that should work.

Is there a way to fire the script each time a lease is updated or created?

Nope, not that I’m aware of. What I do is make a script called DNSUpdate with the above script in it. Then I make a scheduled item that runs that script every 1 min. This seems to work good with very little CPU usage.

If you had an external DNS server that supports DNS updates, you could incorporate this command in the script:

/tool dns-update address=$hostip name=$hostname dns-server=<dns server>

This still requires a schedule to run, there are no events triggered when DHCP lease is obtained.

Great! Thanks so much!

I know Doug already stated this, but I just wanted to confirm that there isn’t a trigger we can access when a lease is given out via DHCP.

If this is true, for informational purposes, does anyone have a complete list of triggerable events in the ROS that can be accessible via scripts?

I would also like to see this documented somewhere.

An official Wiki entry from Mikrotik would be appreciated? I would like to see more in-depth into specific features and functions between different versions. Ex. When was WOL (Wake On LAN) implemented? The reason it’s hard to pinpoint is due to a scattered, and non-standard/consistent documentation.

Just my 2 cents…