mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
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={
|
: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 Comment ($CommentPrefix . $LeaseVal->"mac-address");
|
||||||
:local HostName [ $IfThenElse ([ :len ($LeaseVal->"host-name") ] = 0) \
|
:local HostName [ $IfThenElse ([ :len ($LeaseVal->"host-name") ] = 0) \
|
||||||
[ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ] \
|
[ $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;
|
/ ip dns static add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue