Hi!
I have a script (ddns update) configured on the dhcp server which runs nicely when an IP is leased. But on lease renew it doesn’t run, which I would like it to.
The plan is to drop the dynamic hostnames from the dns after the TTL (the DNS doesn’t know the client is still there) so it needs to be informed on renewals.
but as I understand, the DHCP server is responcible for removing the name at the DNS server. but there does not seems to be an option for that in the /tool/dns-update command (or is there?)
I’m a bit confused. Normally, you use DDNS on a /ip/dhcp-client script (not “DHCP server” mention in top post)…
First, /tool/dns-update uses the RFC scheme to update a DNS server, but few/none “cloud” DNS providers use that method. So /tool/dns-update pretty much work only with a classic BIND9 server (or unbound or perhaps self-hosted/“enterprise” DNS).
A “script-less” approach to DDNS update is just use /ip/cloud to enable DDNS. This will get you a DNS name like xxxx0b119yyy.sn.mynetname.net. And then you can manually add a “CNAME” record on custom DNS domain that point to the sn.mynetname.net name. So RouterOS will do the DDNS IP detection, and your own DNS domain just “aliases” the Mikrotik name to your own. This allow your custom DNS name to resolve, indirectly, via the CNAME to the Mikrotik’s DDNS name, which get the public IP from the router.
Otherwise, the DDNS provider you are using is needed, since different services have different APIs you need in a script. And typically /tool/fetch is needed to do the DDNS update for most services.
Hi,
Maybe a mix-up in terms then. I refer to Dynamic Updates where the DHCP server informs the DNS about which host leased which IP (and for how long).
Which works fine with the “/tool/dns-update” command.
I believe you need an else={ … } in the :if ( $leaseBound = 1 ) { … } statement for the “expired” case. Or, add another :if ($leaseBound = 0) do={} work too for expired dhcp leases.
But your bigger problem is likely that /tool/dns-update does not support a “remove”, or even setting NXDOMAIN or something. So you can update record to 0.0.0.0 or something on expiration, but not remove the name AFAIK.
Thnx!
I was aware of needing the else block but did not built any because I lacked a remove command.
I tried an update to “0.0.0.0” but in the script above the hostname isn’t always (strange, sometimes, not always) found so it doesn’t work.
Also, when trying to ping a host that resolves to 0.0.0.0 the client uses 127.0.0.1 instead.
The testing continues