From 4a0f395fe127f82d35e0ac40af081a2391a36da5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 21 Mar 2023 20:49:43 +0100 Subject: dhcp-to-dns: split fqdn to host name and domain --- dhcp-to-dns.rsc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index 0914330..59daef4 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -63,9 +63,9 @@ $ScriptLock $0 false 10; :local HostName [ $IfThenElse ([ :len ($LeaseVal->"host-name") ] = 0) \ [ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ] \ [ $CharacterReplace ($LeaseVal->"host-name") " " "" ] ]; + :local Domain ([ $IfThenElse ($ServerNameInZone = true) ($LeaseVal->"server" . ".") ] . $Zone); - :local Fqdn ($HostName . "." . [ $IfThenElse ($ServerNameInZone = true) ($LeaseVal->"server" . ".") ] . $Zone); - :local DnsRecord [ /ip/dns/static/find where name=$Fqdn ]; + :local DnsRecord [ /ip/dns/static/find where name=($HostName . "." . $Domain) ]; :if ([ :len $DnsRecord ] > 0) do={ :local DnsIp [ /ip/dns/static/get $DnsRecord address ]; @@ -82,14 +82,14 @@ $ScriptLock $0 false 10; } :if ($DnsIp = $LeaseVal->"address") do={ - $LogPrintExit2 debug $0 ("DNS entry for " . $Fqdn . " does not need updating.") false; + $LogPrintExit2 debug $0 ("DNS entry for " . ($HostName . "." . $Domain) . " does not need updating.") false; } else={ - $LogPrintExit2 info $0 ("Replacing DNS entry for " . $Fqdn . ", new address is " . $LeaseVal->"address" . ".") false; - /ip/dns/static/set name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment $DnsRecord; + $LogPrintExit2 info $0 ("Replacing DNS entry for " . ($HostName . "." . $Domain) . ", new address is " . $LeaseVal->"address" . ".") false; + /ip/dns/static/set name=($HostName . "." . $Domain) address=($LeaseVal->"address") ttl=$Ttl comment=$Comment $DnsRecord; } } else={ - $LogPrintExit2 info $0 ("Adding new DNS entry for " . $Fqdn . ", address is " . $LeaseVal->"address" . ".") false; - /ip/dns/static/add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore; + $LogPrintExit2 info $0 ("Adding new DNS entry for " . ($HostName . "." . $Domain) . ", address is " . $LeaseVal->"address" . ".") false; + /ip/dns/static/add name=($HostName . "." . $Domain) address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore; } } else={ $LogPrintExit2 debug $0 ("No address available... Ignoring.") false; -- cgit v1.2.3-70-g09d2