dhcp-to-dns: allow to specify domain for CNAMEs...

... in network or lease.
This commit is contained in:
Łukasz Witkowski 2026-05-11 17:25:42 +02:00 committed by Christian Hesse
parent 172298f5eb
commit 71df93e011
2 changed files with 15 additions and 1 deletions

View file

@ -91,7 +91,8 @@
:local NetDomain ([ $IfThenElse ([ :len ($NetworkInfo->"name-extra") ] > 0) ($NetworkInfo->"name-extra" . ".") ] . \
[ $EitherOr [ $EitherOr ($NetworkInfo->"domain") ($NetworkVal->"domain") ] $Domain ]);
:local FullA [ :convert transform=lc ($MacDash . "." . $NetDomain) ];
:local FullCN [ :convert transform=lc ($HostName . "." . $NetDomain) ];
:local CNameDomain [ $EitherOr ($LeaseInfo->"cname-domain") ($NetworkInfo->"cname-domain") ];
:local FullCN [ :convert transform=lc ($HostName . "." . [ $EitherOr $CNameDomain $NetDomain ]) ];
:local MacInServer ($LeaseVal->"active-mac-address" . " in " . $LeaseVal->"server");
:local DnsRecord [ /ip/dns/static/find where comment=$Comment type=A ];

View file

@ -84,6 +84,19 @@ Note this information can be configured in wireless access list with
then due to script execution order. Decrease the scheduler interval to
reduce the effect.
### Override domain for CNAME records
By default both the A record (based on mac address) and the CNAME record
(based on host name) use the same domain. You can set a different domain
for CNAME records with `cname-domain=` in network comment:
/ip/dhcp-server/network/add address=10.0.0.0/24 domain=dhcp.example.com comment="cname-domain=example.com";
Adding `cname-domain=` in lease comment has even higher priority:
/ip/dhcp-server/lease/add address=10.0.0.50 comment="cname-domain=example.com" mac-address=00:11:22:33:44:55 server=dhcp;
Frequently asked questions
--------------------------