Here is a script i did to update the DNS static entries from DHCP leases. You need to put it in a dhcp script lease. I have no answer for your script upload question.
Router OS 6.39 at least is needed to get it working.
Be careful if you use it on a large DNS set as it could remove entries. It is designed to keep a clean local DNS set without addresses or domain names duplicates.
A problem using such a DHCP lease script, is that it will only trig for client bounds. This mean that if a client does only renew, and the domain name of the client has been modified in between, the DNS will not be updated. Even if it does renew at the end of the lease period, the script will not execute.
It would be nice if the lease script could trig for other DHCP events, not only bound (renew, release...) so that we can update and remove a DNS entry when there are DHCP lease modifications or releases.
Let me know if you find a solution to this problem.
# Write DNS static record for each DHCP lease
:local topdomain;
:local FullHostName;
:local NoUpdate false;
# Configure your domain
:set topdomain "yourdomain.com";
:if ($leaseBound = 1) do={
:set FullHostName ($"lease-hostname" . "." . $topdomain)
/ip dns static;
:foreach n in [find] do={
# If a static DNS entry is the same as the lease then leave it and mark to not Update it
:if (([get $n name] = $"FullHostName") and ([get $n address] = $leaseActIP)) do={
:set NoUpdate true;
} else={
# If some DNS entry with same fully qualified domain name or same address already exist remove it
:if (([get $n name] = $"FullHostName") or ([get $n address] = $leaseActIP)) do={
:log info ("Removing from Static DNS : " . [get $n name] . " @ " . [get $n address]);
remove $n;
}
}
}
# Add new Static DNS Entry if necessary
:if ($NoUpdate = false) do={
:log info ("Adding to Static DNS : " . $"FullHostName" . " @ " . $leaseActIP);
add name=($"lease-hostname" . "." . $topdomain) address=$leaseActIP;
}
}