I wrote this script and it seems to work well for multiple networks each with it's own domain setting set on a single router.
Can any of you guys take a look at it and check for any stability issues, or think of any scenarios in which it would not function properly?
Any ideas on how to optimise it are also welcome.
/ip dhcp-server lease-script
ros code
:if ($leaseBound=1) do={ :foreach network in=[/ip dhcp-server network find] do={ :local netmask [/ip dhcp-server network get value-name=netmask $network]; :local leaseNetwork [:tostr ($leaseActIP & (~((0.0.0.1 << (32-$netmask))-1)))]; :if ([/ip dhcp-server network find address ~ [:tostr $leaseNetwork]] = $network) do={ :local leaseDomain [/ip dhcp-server network get value-name=domain $network]; :local leaseHostname ([/ip dhcp-server lease get [/ip dhcp-server lease find where active-mac-address=$leaseActMAC]]->"host-name"); :if ([:len $leaseHostname]!=0) do={ /ip dns static add address=$leaseActIP name=($leaseHostname.".".$leaseDomain) ttl=5m; } } } } else={ /ip dns static remove [/ip dns static find where address ~ "$leaseActIP"]; }