dhcp-to-dns: properly handle vanished lease
This commit is contained in:
parent
9c9fb46e4a
commit
23daea2354
1 changed files with 31 additions and 23 deletions
10
dhcp-to-dns
10
dhcp-to-dns
|
|
@ -52,7 +52,14 @@ $ScriptLock $0 false 10;
|
|||
}
|
||||
|
||||
:foreach Lease in=[ / ip dhcp-server lease find where status=bound ] do={
|
||||
:local LeaseVal [ / ip dhcp-server lease get $Lease ];
|
||||
:local LeaseVal;
|
||||
:do {
|
||||
:set LeaseVal [ / ip dhcp-server lease get $Lease ];
|
||||
} on-error={
|
||||
$LogPrintExit2 debug $0 ("A lease just vanished, ignoring.") false;
|
||||
}
|
||||
|
||||
:if ([ :typeof $LeaseVal ] = "array") do={
|
||||
:local Comment ($CommentPrefix . $LeaseVal->"mac-address");
|
||||
:local HostName [ $IfThenElse ([ :len ($LeaseVal->"host-name") ] = 0) \
|
||||
[ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ] \
|
||||
|
|
@ -83,3 +90,4 @@ $ScriptLock $0 false 10;
|
|||
/ ip dns static add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue