mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-17 16:21:15 +02:00
dhcp-to-dns: use $LogPrintExit
This commit is contained in:
parent
be5b6e0687
commit
554308a399
1 changed files with 8 additions and 7 deletions
15
dhcp-to-dns
15
dhcp-to-dns
|
@ -4,12 +4,13 @@
|
||||||
#
|
#
|
||||||
# check DHCP leases and add/remove/update DNS entries
|
# check DHCP leases and add/remove/update DNS entries
|
||||||
|
|
||||||
:global CharacterReplace;
|
|
||||||
|
|
||||||
:global Domain;
|
:global Domain;
|
||||||
:global HostNameInZone;
|
:global HostNameInZone;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
|
||||||
|
:global CharacterReplace;
|
||||||
|
:global LogPrintExit;
|
||||||
|
|
||||||
:local Zone;
|
:local Zone;
|
||||||
:if ($HostNameInZone = true) do={
|
:if ($HostNameInZone = true) do={
|
||||||
:set Zone ("dhcp." . $Identity . "." . $Domain);
|
:set Zone ("dhcp." . $Identity . "." . $Domain);
|
||||||
|
@ -23,10 +24,10 @@
|
||||||
:local DnsRecordVal [ / ip dns static get $DnsRecord ];
|
:local DnsRecordVal [ / ip dns static get $DnsRecord ];
|
||||||
:local MacAddress [ $CharacterReplace ($DnsRecordVal->"comment") $CommentPrefix "" ];
|
:local MacAddress [ $CharacterReplace ($DnsRecordVal->"comment") $CommentPrefix "" ];
|
||||||
:if ([ / ip dhcp-server lease print count-only where mac-address=$MacAddress address=($DnsRecordVal->"address") dynamic=yes status=bound ] > 0) do={
|
:if ([ / ip dhcp-server lease print count-only where mac-address=$MacAddress address=($DnsRecordVal->"address") dynamic=yes status=bound ] > 0) do={
|
||||||
:log debug ("Lease for " . $MacAddress . " (" . $DnsRecordVal->"host-name" . ") still exists. Not deleting DNS entry.");
|
$LogPrintExit debug ("Lease for " . $MacAddress . " (" . $DnsRecordVal->"host-name" . ") still exists. Not deleting DNS entry.") false;
|
||||||
} else={
|
} else={
|
||||||
:local Found false;
|
:local Found false;
|
||||||
:log info ("Lease expired for " . $MacAddress . " (" . $DnsRecordVal->"name" . "), deleting DNS entry.");
|
$LogPrintExit info ("Lease expired for " . $MacAddress . " (" . $DnsRecordVal->"name" . "), deleting DNS entry.") false;
|
||||||
/ ip dns static remove $DnsRecord;
|
/ ip dns static remove $DnsRecord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,13 +55,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($DnsIp = $LeaseVal->"address") do={
|
:if ($DnsIp = $LeaseVal->"address") do={
|
||||||
:log debug ("DNS entry for " . $Fqdn . " does not need updating.");
|
$LogPrintExit debug ("DNS entry for " . $Fqdn . " does not need updating.") false;
|
||||||
} else={
|
} else={
|
||||||
:log info ("Replacing DNS entry for " . $Fqdn . ", new address is " . $LeaseVal->"address" . ".");
|
$LogPrintExit info ("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;
|
/ ip dns static set name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment $DnsRecord;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
:log info ("Adding new DNS entry for " . $Fqdn . ", address is " . $LeaseVal->"address" . ".");
|
$LogPrintExit info ("Adding new DNS entry for " . $Fqdn . ", address is " . $LeaseVal->"address" . ".") false;
|
||||||
/ ip dns static add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment;
|
/ ip dns static add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue