Compare commits

...

4 commits

Author SHA1 Message Date
Christian Hesse
b462964455 update list of contributors 2026-05-11 22:12:19 +02:00
Łukasz Witkowski
96794c85e1 dhcp-to-dns: allow to specify domain for CNAMEs...
... in network or lease.
2026-05-11 22:12:19 +02:00
Łukasz Witkowski
e195391bec dhcp-to-dns: set $LeaseInfo 2026-05-11 22:12:19 +02:00
Łukasz Witkowski
da8ce886ff dhcp-to-dns: convert DNS names to lower case 2026-05-11 22:12:19 +02:00
3 changed files with 19 additions and 3 deletions

View file

@ -23,6 +23,7 @@ for details!
* [Ignacio Serrano](mailto:ignic@ignic.com) (@ignic) * [Ignacio Serrano](mailto:ignic@ignic.com) (@ignic)
* [Ilya Kulakov](mailto:kulakov.ilya@gmail.com) (@Kentzo) * [Ilya Kulakov](mailto:kulakov.ilya@gmail.com) (@Kentzo)
* [Leonardo David Monteiro](mailto:leo@cub3.xyz) (@leosfsm) * [Leonardo David Monteiro](mailto:leo@cub3.xyz) (@leosfsm)
* [Łukasz Witkowski](mailto:witul@skyhost.pl) (@witul)
* [Michael Gisbers](mailto:michael@gisbers.de) (@mgisbers) * [Michael Gisbers](mailto:michael@gisbers.de) (@mgisbers)
* [Miquel Bonastre](mailto:mbonastre@yahoo.com) (@mbonastre) * [Miquel Bonastre](mailto:mbonastre@yahoo.com) (@mbonastre)
* @netravnen * @netravnen

View file

@ -66,6 +66,7 @@
$LogPrint debug $ScriptName ("A lease just vanished, ignoring."); $LogPrint debug $ScriptName ("A lease just vanished, ignoring.");
:continue; :continue;
} }
:local LeaseInfo [ $ParseKeyValueStore ($LeaseVal->"comment") ];
:if ([ :len ($LeaseVal->"active-address") ] = 0) do={ :if ([ :len ($LeaseVal->"active-address") ] = 0) do={
$LogPrint debug $ScriptName ("No address available... Ignoring."); $LogPrint debug $ScriptName ("No address available... Ignoring.");
@ -86,11 +87,12 @@
:local Comment ($CommentPrefix . ", macaddress=" . $LeaseVal->"active-mac-address" . ", server=" . $LeaseVal->"server"); :local Comment ($CommentPrefix . ", macaddress=" . $LeaseVal->"active-mac-address" . ", server=" . $LeaseVal->"server");
:local MacDash [ $CleanName ($LeaseVal->"active-mac-address") ]; :local MacDash [ $CleanName ($LeaseVal->"active-mac-address") ];
:local HostName [ $CleanName [ $EitherOr ([ $ParseKeyValueStore ($LeaseVal->"comment") ]->"hostname") ($LeaseVal->"host-name") ] ]; :local HostName [ $CleanName [ $EitherOr ($LeaseInfo->"hostname") ($LeaseVal->"host-name") ] ];
:local NetDomain ([ $IfThenElse ([ :len ($NetworkInfo->"name-extra") ] > 0) ($NetworkInfo->"name-extra" . ".") ] . \ :local NetDomain ([ $IfThenElse ([ :len ($NetworkInfo->"name-extra") ] > 0) ($NetworkInfo->"name-extra" . ".") ] . \
[ $EitherOr [ $EitherOr ($NetworkInfo->"domain") ($NetworkVal->"domain") ] $Domain ]); [ $EitherOr [ $EitherOr ($NetworkInfo->"domain") ($NetworkVal->"domain") ] $Domain ]);
:local FullA ($MacDash . "." . $NetDomain); :local FullA [ :convert transform=lc ($MacDash . "." . $NetDomain) ];
:local FullCN ($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 MacInServer ($LeaseVal->"active-mac-address" . " in " . $LeaseVal->"server");
:local DnsRecord [ /ip/dns/static/find where comment=$Comment type=A ]; :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 then due to script execution order. Decrease the scheduler interval to
reduce the effect. 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 Frequently asked questions
-------------------------- --------------------------