From ed26d69842308ad0acb40b902224ca62aafe1737 Mon Sep 17 00:00:00 2001 From: netztrip Date: Sat, 1 Aug 2020 16:01:02 +0200 Subject: [PATCH] dhcp-to-dns: add support for pool name in fqdn --- dhcp-to-dns | 8 +++++++- doc/dhcp-to-dns.md | 1 + global-config | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dhcp-to-dns b/dhcp-to-dns index 352b53f0..bf54844e 100644 --- a/dhcp-to-dns +++ b/dhcp-to-dns @@ -10,6 +10,7 @@ :global HostNameInZone; :global Identity; :global PrefixInZone; +:global PoolInZone; :global CharacterReplace; :global IfThenElse; @@ -46,7 +47,12 @@ [ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ] \ [ $CharacterReplace ($LeaseVal->"host-name") " " "" ] ]; - :local Fqdn ($HostName . "." . $Zone); + :local Server [ / ip dhcp-server find where name=($LeaseVal->"server") ]; + :local ServerVal [ / ip dhcp-server get $Server ]; + :local Pool ($ServerVal->"address-pool"); + :local ZoneVal ([ $IfThenElse ($PoolInZone = true) ($Pool . ".") ] . $Zone); + + :local Fqdn ($HostName . "." . $ZoneVal); :local DnsRecord [ / ip dns static find where name=$Fqdn ]; :if ([ :len $DnsRecord ] > 0) do={ :local DnsIp [ / ip dns static get $DnsRecord address ]; diff --git a/doc/dhcp-to-dns.md b/doc/dhcp-to-dns.md index 9f8cb8b4..5488ff38 100644 --- a/doc/dhcp-to-dns.md +++ b/doc/dhcp-to-dns.md @@ -33,6 +33,7 @@ The configuration goes to `global-config-overlay`, these are the parameters: * `Domain`: the domain used for dns records * `HostNameInZone`: whether or not to add the dhcp/dns server's hostname +* `PoolInZone`: whether or not to add the dhcp server's pool name See also -------- diff --git a/global-config b/global-config index 4e5fd4ac..c09b8203 100644 --- a/global-config +++ b/global-config @@ -14,6 +14,7 @@ :global Domain "example.com"; :global HostNameInZone true; :global PrefixInZone true; +:global PoolInZone false; # These addresses are used to send e-mails to. The to-address needs # to be filled; cc-address can be empty, one address or a comma