mirror of
https://github.com/nymurbd/MikroTik-scripts.git
synced 2025-08-17 16:21:01 +02:00
dhcp-to-dns: use $IfThenElse
This commit is contained in:
parent
6dfd8ed41a
commit
e709af4c4d
1 changed files with 7 additions and 11 deletions
18
dhcp-to-dns
18
dhcp-to-dns
|
@ -12,15 +12,12 @@
|
||||||
:global PrefixInZone;
|
:global PrefixInZone;
|
||||||
|
|
||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
|
:global IfThenElse;
|
||||||
:global LogPrintExit;
|
:global LogPrintExit;
|
||||||
|
|
||||||
:local Zone $Domain;
|
:local Zone \
|
||||||
:if ($HostNameInZone = true) do={
|
([ $IfThenElse ($PrefixInZone = true) "dhcp." ] . \
|
||||||
:set Zone ($Identity . "." . $Zone);
|
[ $IfThenElse ($HostNameInZone = true) ($Identity . ".") ] . $Domain);
|
||||||
}
|
|
||||||
:if ($PrefixInZone = true) do={
|
|
||||||
:set Zone ("dhcp." . $Zone);
|
|
||||||
}
|
|
||||||
:local Ttl 5m;
|
:local Ttl 5m;
|
||||||
:local CommentPrefix "managed by dhcp-to-dns for ";
|
:local CommentPrefix "managed by dhcp-to-dns for ";
|
||||||
|
|
||||||
|
@ -45,10 +42,9 @@
|
||||||
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={
|
:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={
|
||||||
:local LeaseVal [ / ip dhcp-server lease get $Lease ];
|
:local LeaseVal [ / ip dhcp-server lease get $Lease ];
|
||||||
:local Comment ($CommentPrefix . $LeaseVal->"mac-address");
|
:local Comment ($CommentPrefix . $LeaseVal->"mac-address");
|
||||||
:local HostName [ $CharacterReplace ($LeaseVal->"host-name") " " "" ];
|
:local HostName [ $IfThenElse ([ :len ($LeaseVal->"host-name") ] = 0) \
|
||||||
:if ($HostName = "") do={
|
[ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ] \
|
||||||
:set HostName [ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ];
|
[ $CharacterReplace ($LeaseVal->"host-name") " " "" ] ];
|
||||||
}
|
|
||||||
|
|
||||||
:local Fqdn ($HostName . "." . $Zone);
|
:local Fqdn ($HostName . "." . $Zone);
|
||||||
:local DnsRecord [ / ip dns static find where name=$Fqdn ];
|
:local DnsRecord [ / ip dns static find where name=$Fqdn ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue