diff options
author | Christian Hesse <mail@eworm.de> | 2023-03-22 10:21:31 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-03-22 21:53:32 +0100 |
commit | 295ccb570d98dd3f782da5e0272d62bf2698a836 (patch) | |
tree | dcec4a7d6212029654ffa53856cc634ab5db3fa4 /dhcp-to-dns.rsc | |
parent | b13a53531bcd2b557b207810110b8987b93208b6 (diff) |
dhcp-to-dns: update cname record on changed host name
Diffstat (limited to 'dhcp-to-dns.rsc')
-rw-r--r-- | dhcp-to-dns.rsc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index aa71e4c..75b3fbf 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -81,6 +81,12 @@ $ScriptLock $0 false 10; $LogPrintExit2 info $0 ("Replacing DNS entry for " . ($MacDash . "." . $Domain) . ", new address is " . $LeaseVal->"address" . ".") false; /ip/dns/static/set address=($LeaseVal->"address") $DnsRecord; } + + :local Cname [ /ip/dns/static/find where type=CNAME cname=($MacDash . "." . $Domain) comment=$Comment ]; + :if ([ :len $Cname ] > 0 && [ /ip/dns/static/get $Cname name ] != ($HostName . "." . $Domain)) do={ + $LogPrintExit2 info $0 ("Host name changed, updating CNAME (pointing to " . ($MacDash . "." . $Domain) . ") to " . ($HostName . "." . $Domain) . ".") false; + /ip/dns/static/set name=($HostName . "." . $Domain) $Cname; + } } else={ $LogPrintExit2 info $0 ("Adding new DNS entry for " . ($MacDash . "." . $Domain) . ", address is " . $LeaseVal->"address" . ".") false; /ip/dns/static/add name=($MacDash . "." . $Domain) type=A address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore; |