diff options
author | Christian Hesse <mail@eworm.de> | 2023-04-13 00:32:13 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-04-24 22:26:26 +0200 |
commit | ee94024dcaa59333f03d90f342e550a5f3ab40f2 (patch) | |
tree | 924f31c5cf5bbb3b7234f0eb1354edf573b591ab /dhcp-to-dns.rsc | |
parent | ac5d84173f0a5b019ed59051c142837f76b5549e (diff) |
dhcp-to-dns: get domain from dhcp server's network definitionchange-99
Diffstat (limited to 'dhcp-to-dns.rsc')
-rw-r--r-- | dhcp-to-dns.rsc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index d310a73..b15511e 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -13,10 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :global Domain; -:global HostNameInZone; :global Identity; -:global PrefixInZone; -:global ServerNameInZone; :global CharacterReplace; :global EitherOr; @@ -27,9 +24,6 @@ $ScriptLock $0 false 10; -:local Zone \ - ([ $IfThenElse ($PrefixInZone = true) "dhcp." ] . \ - [ $IfThenElse ($HostNameInZone = true) ($Identity . ".") ] . $Domain); :local Ttl 5m; :local CommentPrefix ("managed by " . $0 . " for "); :local CommentString ("--- " . $0 . " above ---"); @@ -70,7 +64,14 @@ $ScriptLock $0 false 10; :local Comment ($CommentPrefix . $LeaseVal->"mac-address"); :local MacDash [ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ]; :local HostName [ $CharacterReplace [ $EitherOr ([ $ParseKeyValueStore ($LeaseVal->"comment") ]->"hostname") ($LeaseVal->"host-name") ] " " "" ]; - :local NetDomain ([ $IfThenElse ($ServerNameInZone = true) ($LeaseVal->"server" . ".") ] . $Zone); + :local Network [ /ip/dhcp-server/network/find where ($LeaseVal->"address") in address ]; + :local NetworkVal; + :if ([ :len $Network ] > 0) do={ + :set NetworkVal [ /ip/dhcp-server/network/get ($Network->0) ]; + } + :local NetworkInfo [ $ParseKeyValueStore ($NetworkVal->"comment") ]; + :local NetDomain ([ $IfThenElse ([ :len ($NetworkInfo->"name-extra") ] > 0) ($NetworkInfo->"name-extra" . ".") ] . \ + [ $EitherOr [ $EitherOr ($NetworkInfo->"domain") ($NetworkVal->"domain") ] $Domain ]); :local DnsRecord [ /ip/dns/static/find where comment=$Comment (!type or type=A) ]; :if ([ :len $DnsRecord ] > 0) do={ |