diff options
author | Christian Hesse <mail@eworm.de> | 2019-11-12 12:49:28 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2019-11-12 12:49:28 +0100 |
commit | 91776d3388e3b0d8082d7e5acaa18e7116080d7c (patch) | |
tree | 19777eb084c8fe9eca6694b57d902db76af5ecc2 /dhcp-to-dns | |
parent | 9d5c566b1cce5cd24dab0087ea94fcaa582794c8 (diff) |
dhcp-to-dns: handle duplicate mac-address and host-name
* several leases for one mac address (changed client id, different net):
-> take address from last lease
Most likely this is the same devices which booted different OS or
changed to different network.
* several leases for one host name:
-> take address from first lease
We see either different devices with same name or one device with
several network interfaces. Keep the first name to mitigate stealing
dns name.
Diffstat (limited to 'dhcp-to-dns')
-rw-r--r-- | dhcp-to-dns | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/dhcp-to-dns b/dhcp-to-dns index 7cd7fa0..e403881 100644 --- a/dhcp-to-dns +++ b/dhcp-to-dns @@ -44,9 +44,14 @@ :if ([ :len $DnsRecord ] > 0) do={ :local DnsIp [ / ip dns static get $DnsRecord address ]; - :local HostLeases [ / ip dhcp-server lease find where mac-address=($LeaseVal->"mac-address") dynamic=yes ]; - :if ([ :len $HostLeases ] > 1) do={ - :set ($LeaseVal->"address") [ / ip dhcp-server lease get ($HostLeases->([ :len $HostLeases ] - 1)) address ]; + :local DupMacLeases [ / ip dhcp-server lease find where mac-address=($LeaseVal->"mac-address") dynamic=yes ]; + :if ([ :len $DupMacLeases ] > 1) do={ + :set ($LeaseVal->"address") [ / ip dhcp-server lease get ($DupMacLeases->([ :len $DupMacLeases ] - 1)) address ]; + } + + :local DupHostLeases [ / ip dhcp-server lease find where host-name=($LeaseVal->"host-name") dynamic=yes ]; + :if ([ :len $DupHostLeases ] > 1) do={ + :set ($LeaseVal->"address") [ / ip dhcp-server lease get ($DupHostLeases->0) address ]; } :if ($DnsIp = $LeaseVal->"address") do={ |