From b5e6b9cb55b5575b5248affef085584dc51f9b09 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 16 Mar 2026 11:27:14 +0100 Subject: [PATCH] dhcp-to-dns: support to ignore networks Closes: https://github.com/eworm-de/routeros-scripts/issues/119 --- dhcp-to-dns.rsc | 12 +++++++++--- doc/dhcp-to-dns.md | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index 74d2e9b3..692403ba 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -72,15 +72,21 @@ :continue; } - :local Comment ($CommentPrefix . ", macaddress=" . $LeaseVal->"active-mac-address" . ", server=" . $LeaseVal->"server"); - :local MacDash [ $CleanName ($LeaseVal->"active-mac-address") ]; - :local HostName [ $CleanName [ $EitherOr ([ $ParseKeyValueStore ($LeaseVal->"comment") ]->"hostname") ($LeaseVal->"host-name") ] ]; :local Network [ /ip/dhcp-server/network/find where ($LeaseVal->"active-address") in address ]; :local NetworkVal; :if ([ :len $Network ] > 0) do={ :set NetworkVal [ /ip/dhcp-server/network/get ($Network->0) ]; } :local NetworkInfo [ $ParseKeyValueStore ($NetworkVal->"comment") ]; + + :if ($NetworkInfo->"dns-ignore" = true) do={ + $LogPrint debug $ScriptName ("Lease for " . $LeaseVal->"active-mac-address" . " is in ignored network... Skipping."); + :continue; + } + + :local Comment ($CommentPrefix . ", macaddress=" . $LeaseVal->"active-mac-address" . ", server=" . $LeaseVal->"server"); + :local MacDash [ $CleanName ($LeaseVal->"active-mac-address") ]; + :local HostName [ $CleanName [ $EitherOr ([ $ParseKeyValueStore ($LeaseVal->"comment") ]->"hostname") ($LeaseVal->"host-name") ] ]; :local NetDomain ([ $IfThenElse ([ :len ($NetworkInfo->"name-extra") ] > 0) ($NetworkInfo->"name-extra" . ".") ] . \ [ $EitherOr [ $EitherOr ($NetworkInfo->"domain") ($NetworkVal->"domain") ] $Domain ]); :local FullA ($MacDash . "." . $NetDomain); diff --git a/doc/dhcp-to-dns.md b/doc/dhcp-to-dns.md index a1a211c6..bf0db384 100644 --- a/doc/dhcp-to-dns.md +++ b/doc/dhcp-to-dns.md @@ -50,8 +50,12 @@ A bound lease for mac address `00:11:22:33:44:55` with ip address `10.0.0.50` would result in an A record `00-11-22-33-44-55.example.com` pointing to the given ip address. -Additional options can be given from comment, to add an extra level in -dns name or define a different domain. +Additional options can be given from comment, first of all you can opt-out +for specific networks: + + /ip/dhcp-server/network/add address=10.0.0.0/24 domain=example.com comment="dns-ignore=true"; + +Use this to add an extra level in dns name or define a different domain. /ip/dhcp-server/network/add address=10.0.0.0/24 domain=example.com comment="domain=another-domain.com, name-extra=dhcp";