mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-06-04 01:32:45 +00:00
dhcp-to-dns: add cname-domain override at global, network and lease level
Allow the CNAME record domain to differ from the A record domain. Priority: per-lease comment > per-network comment > global config. Also refactor ParseKeyValueStore call for lease comment into a local variable to avoid parsing it twice.
This commit is contained in:
parent
cd4052ba6b
commit
b6e933406a
3 changed files with 31 additions and 2 deletions
|
|
@ -17,6 +17,7 @@
|
|||
:local ScriptName [ :jobname ];
|
||||
|
||||
:global Domain;
|
||||
:global DhcpToDnsCnameDomain;
|
||||
:global Identity;
|
||||
|
||||
:global CleanName;
|
||||
|
|
@ -71,7 +72,8 @@
|
|||
:if ([ :len ($LeaseVal->"active-address") ] > 0) do={
|
||||
: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 LeaseInfo [ $ParseKeyValueStore ($LeaseVal->"comment") ];
|
||||
:local HostName [ $CleanName [ $EitherOr ($LeaseInfo->"hostname") ($LeaseVal->"host-name") ] ];
|
||||
:local Network [ /ip/dhcp-server/network/find where ($LeaseVal->"active-address") in address ];
|
||||
:local NetworkVal;
|
||||
:if ([ :len $Network ] > 0) do={
|
||||
|
|
@ -81,7 +83,8 @@
|
|||
:local NetDomain ([ $IfThenElse ([ :len ($NetworkInfo->"name-extra") ] > 0) ($NetworkInfo->"name-extra" . ".") ] . \
|
||||
[ $EitherOr [ $EitherOr ($NetworkInfo->"domain") ($NetworkVal->"domain") ] $Domain ]);
|
||||
:local FullA ($MacDash . "." . $NetDomain);
|
||||
:local FullCN ($HostName . "." . $NetDomain);
|
||||
:local CnameDomain [ $EitherOr ($LeaseInfo->"cname-domain") [ $EitherOr ($NetworkInfo->"cname-domain") $DhcpToDnsCnameDomain ] ];
|
||||
:local FullCN ($HostName . "." . [ $IfThenElse ([ :len $CnameDomain ] > 0) $CnameDomain $NetDomain ]);
|
||||
:local MacInServer ($LeaseVal->"active-mac-address" . " in " . $LeaseVal->"server");
|
||||
|
||||
:local DnsRecord [ /ip/dns/static/find where comment=$Comment type=A ];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue