working 100% RouterOS 6.40.9 bugfix
Code: Select all
:do {
:if ($leaseBound=1) do={
:local HostName [/ip dhcp-server lease get number=[find where mac-address=$leaseActMAC] host-name];
if ([:len $HostName]=0) do={:log error message="host-name Not Available";:error};
:local Domain [/ip dhcp-server network get number=[find where $leaseActIP in address] domain];
if ([:len $Domain]=0) do={:log error message="domain Not Available";:error};
:do {/ip dns static
remove numbers=[find where name=($HostName . "." . $Domain)];
add name=($HostName . "." . $Domain) address=$leaseActIP ttl=600s;
} on-error={:log error message="Adding FQDN Failed"}
}
:if ($leaseBound=0) do={
:do {/ip dns static
remove numbers=[find where address=$leaseActIP];
} on-error={:log error message="Removing FQDN Failed"}
} } on-error={:log error message="lease-script failed..."}