mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
dhcp-to-dns: split fqdn to host name and domain
This commit is contained in:
parent
682a09c94b
commit
4a0f395fe1
1 changed files with 7 additions and 7 deletions
|
@ -63,9 +63,9 @@ $ScriptLock $0 false 10;
|
|||
:local HostName [ $IfThenElse ([ :len ($LeaseVal->"host-name") ] = 0) \
|
||||
[ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ] \
|
||||
[ $CharacterReplace ($LeaseVal->"host-name") " " "" ] ];
|
||||
:local Domain ([ $IfThenElse ($ServerNameInZone = true) ($LeaseVal->"server" . ".") ] . $Zone);
|
||||
|
||||
:local Fqdn ($HostName . "." . [ $IfThenElse ($ServerNameInZone = true) ($LeaseVal->"server" . ".") ] . $Zone);
|
||||
:local DnsRecord [ /ip/dns/static/find where name=$Fqdn ];
|
||||
:local DnsRecord [ /ip/dns/static/find where name=($HostName . "." . $Domain) ];
|
||||
:if ([ :len $DnsRecord ] > 0) do={
|
||||
:local DnsIp [ /ip/dns/static/get $DnsRecord address ];
|
||||
|
||||
|
@ -82,14 +82,14 @@ $ScriptLock $0 false 10;
|
|||
}
|
||||
|
||||
:if ($DnsIp = $LeaseVal->"address") do={
|
||||
$LogPrintExit2 debug $0 ("DNS entry for " . $Fqdn . " does not need updating.") false;
|
||||
$LogPrintExit2 debug $0 ("DNS entry for " . ($HostName . "." . $Domain) . " does not need updating.") false;
|
||||
} else={
|
||||
$LogPrintExit2 info $0 ("Replacing DNS entry for " . $Fqdn . ", new address is " . $LeaseVal->"address" . ".") false;
|
||||
/ip/dns/static/set name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment $DnsRecord;
|
||||
$LogPrintExit2 info $0 ("Replacing DNS entry for " . ($HostName . "." . $Domain) . ", new address is " . $LeaseVal->"address" . ".") false;
|
||||
/ip/dns/static/set name=($HostName . "." . $Domain) address=($LeaseVal->"address") ttl=$Ttl comment=$Comment $DnsRecord;
|
||||
}
|
||||
} else={
|
||||
$LogPrintExit2 info $0 ("Adding new DNS entry for " . $Fqdn . ", address is " . $LeaseVal->"address" . ".") false;
|
||||
/ip/dns/static/add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore;
|
||||
$LogPrintExit2 info $0 ("Adding new DNS entry for " . ($HostName . "." . $Domain) . ", address is " . $LeaseVal->"address" . ".") false;
|
||||
/ip/dns/static/add name=($HostName . "." . $Domain) address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore;
|
||||
}
|
||||
} else={
|
||||
$LogPrintExit2 debug $0 ("No address available... Ignoring.") false;
|
||||
|
|
Loading…
Reference in a new issue