Sep 222016
 

I like my switch/routers from Mikrotik. While not flawless, they are working well, have a descent command line interface and a usable web (and Windows) GUI. They got all features I need and are stable.

One missing feature however was that DHCP leses did not get a DNS entry. The simple workaround was that stuff which should get DNS gets a static IP. Anything else doesn’t and thus is not reachable by DNS. Was not a big deal until I used Vagrant which can build VMs (via VirtualBox). Now I got plenty VMs which I simply bridge on the normal LAN. But in order to connect to them outside of “vagrant ssh nodeX”, I needed to have their IP. Vagrant can tell me, as can the VM itself when I connect via “vagrant ssh”, but all this is way more complex than simply using DNS. dnsmasq does that automatically, but not the DHCP/DNS combo on RouterOS.

Scripts to the rescue!

https://www.tolaris.com/2014/09/27/synchronising-dhcp-and-dns-on-mikrotik-routers/ has a nice one which does what it’s supposed to do. Relying on the TTL to be different from static DNS entries, it’ll create or delete DNS records which according to DHCP leases should or should not exist.

screenshot_20160922_163849

One important hint: you need to allow the script to read/write “things”. And the scheduler when running the script.

screenshot_20160922_164130

TTL for DHCP is set to 15min. TTL for static enteries is 1d. The script runs every 5min.