mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-06-03 17:22:40 +00:00
dhcp-to-dns: add cname-domain override and normalize names to lowercase
This commit is contained in:
parent
9ba1dc8347
commit
6b2ec93ee6
3 changed files with 33 additions and 3 deletions
|
|
@ -17,6 +17,7 @@
|
|||
:local ScriptName [ :jobname ];
|
||||
|
||||
:global Domain;
|
||||
:global DhcpToDnsCnameDomain;
|
||||
:global Identity;
|
||||
|
||||
:global CleanName;
|
||||
|
|
@ -26,6 +27,7 @@
|
|||
:global LogPrintOnce;
|
||||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
:global ToLower;
|
||||
|
||||
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
|
||||
:set ExitOK true;
|
||||
|
|
@ -70,8 +72,9 @@
|
|||
|
||||
: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 MacDash [ $ToLower [ $CleanName ($LeaseVal->"active-mac-address") ] ];
|
||||
:local LeaseInfo [ $ParseKeyValueStore ($LeaseVal->"comment") ];
|
||||
:local HostName [ $ToLower [ $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 +84,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