diff options
author | Christian Hesse <mail@eworm.de> | 2023-04-12 23:13:26 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-04-24 22:26:26 +0200 |
commit | 4c416cb39eac3981ef2d5db727b45f3dcfdda4c4 (patch) | |
tree | baae918a6c32890103d633dda6446c24787807e0 | |
parent | f3876b0637140db2e242cddb5b38b128bcaa7473 (diff) |
dhcp-to-dns: handle duplicate leases earlier
-rw-r--r-- | dhcp-to-dns.rsc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index 507bda6..e6970ff 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -57,6 +57,11 @@ $ScriptLock $0 false 10; :local LeaseVal; :do { :set LeaseVal [ /ip/dhcp-server/lease/get $Lease ]; + :local DupMacLeases [ /ip/dhcp-server/lease/find where mac-address=($LeaseVal->"mac-address") status=bound ]; + :if ([ :len $DupMacLeases ] > 1) do={ + $LogPrintExit2 debug $0 ("Multiple bound leases found for mac-address " . ($LeaseVal->"mac-address") . ", using last one.") false; + :set LeaseVal [ /ip/dhcp-server/lease/get ($DupMacLeases->([ :len $DupMacLeases ] - 1)) ]; + } } on-error={ $LogPrintExit2 debug $0 ("A lease just vanished, ignoring.") false; } @@ -71,12 +76,6 @@ $ScriptLock $0 false 10; :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") status=bound ]; - :if ([ :len $DupMacLeases ] > 1) do={ - $LogPrintExit2 debug $0 ("Multiple bound leases found for mac-address " . ($LeaseVal->"mac-address") . ", using ip address of last one.") false; - :set ($LeaseVal->"address") [ /ip/dhcp-server/lease/get ($DupMacLeases->([ :len $DupMacLeases ] - 1)) address ]; - } - :if ($DnsIp = $LeaseVal->"address") do={ $LogPrintExit2 debug $0 ("DNS entry for " . ($MacDash . "." . $Domain) . " does not need updating.") false; } else={ |