diff options
author | Christian Hesse <mail@eworm.de> | 2020-01-06 08:19:16 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-01-06 09:40:24 +0100 |
commit | 0560f828d1f02a9c145806af351faa91fda6b8bf (patch) | |
tree | 720d2b7f7398c7d8c9225039f7dee9ea02b8591a | |
parent | cf79e6c473e8d840aee32922cdc5efb00aa67900 (diff) |
dhcp-to-dns: act on bound leases only
-rw-r--r-- | dhcp-to-dns | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/dhcp-to-dns b/dhcp-to-dns index d37c469..5343513 100644 --- a/dhcp-to-dns +++ b/dhcp-to-dns @@ -22,7 +22,7 @@ :foreach DnsRecord in=[ / ip dns static find where comment ~ $CommentPrefix ] do={ :local DnsRecordVal [ / ip dns static get $DnsRecord ]; :local MacAddress [ $CharacterReplace ($DnsRecordVal->"comment") $CommentPrefix "" ]; - :if ([ / ip dhcp-server lease print count-only where mac-address=$MacAddress address=($DnsRecordVal->"address") dynamic=yes ] > 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."); } else={ :local Found false; @@ -31,7 +31,7 @@ } } -:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes ] do={ +:foreach Lease in=[ / ip dhcp-server lease find where dynamic=yes status=bound ] do={ :local LeaseVal [ / ip dhcp-server lease get $Lease ]; :local Comment ($CommentPrefix . $LeaseVal->"mac-address"); :local HostName [ $CharacterReplace ($LeaseVal->"host-name") " " "" ]; @@ -44,13 +44,13 @@ :if ([ :len $DnsRecord ] > 0) do={ :local DnsIp [ / ip dns static get $DnsRecord address ]; - :local DupMacLeases [ / ip dhcp-server lease find where mac-address=($LeaseVal->"mac-address") dynamic=yes ]; + :local DupMacLeases [ / ip dhcp-server lease find where mac-address=($LeaseVal->"mac-address") dynamic=yes status=bound ]; :if ([ :len $DupMacLeases ] > 1) do={ :set ($LeaseVal->"address") [ / ip dhcp-server lease get ($DupMacLeases->([ :len $DupMacLeases ] - 1)) address ]; } :if ([ :len ($LeaseVal->"host-name") ] > 0) do={ - :set ($LeaseVal->"address") [ / ip dhcp-server lease get ([ find where host-name=($LeaseVal->"host-name") dynamic=yes ]->0) address ]; + :set ($LeaseVal->"address") [ / ip dhcp-server lease get ([ find where host-name=($LeaseVal->"host-name") dynamic=yes status=bound ]->0) address ]; } :if ($DnsIp = $LeaseVal->"address") do={ |