diff options
author | Christian Hesse <mail@eworm.de> | 2023-03-25 22:31:56 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-03-28 11:42:58 +0200 |
commit | 40f0d54ea89b701afbbc1cfa2ade8913c4d137eb (patch) | |
tree | 870a9e9221159dc73859547bb511e5ec44180b35 | |
parent | b22a84ed0fe876f75b70e918c68835a01d67025c (diff) |
dhcp-to-dns: add cname if host name appears for existing record
-rw-r--r-- | dhcp-to-dns.rsc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index 75b3fbf..b925fdb 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -83,6 +83,10 @@ $ScriptLock $0 false 10; } :local Cname [ /ip/dns/static/find where type=CNAME cname=($MacDash . "." . $Domain) comment=$Comment ]; + :if ([ :len $Cname ] = 0 && [ :len $HostName ] > 0) do={ + $LogPrintExit2 info $0 ("Host name appeared, adding CNAME " . ($HostName . "." . $Domain) . " pointing to " . ($MacDash . "." . $Domain) . ".") false; + /ip/dns/static/add name=($HostName . "." . $Domain) type=CNAME cname=($MacDash . "." . $Domain) ttl=$Ttl comment=$Comment place-before=$PlaceBefore; + } :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; |