I would like to share the script to update dyndns.com IP.
I Started from existing script to assembly the one I need, I use it having 2x ISP (main and backup, not aggregated) to update DNS in case of failover of the primary connection and vice-versa.
Code: Select all
# print some debug info
:log info ("<<<< RUNNING SCRIPT DYNDNS.COM UPDATE >>>>")
:local ddnsuser <yourUsername>
:local ddnspass <yourPassword>
:local ddnshost <yourDynDnsHost>
:local ipddns [:resolve $ddnshost];
:log info ("DynDNS script: Registered = $ipddns")
# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.com" src-path="/" dst-path="/dyndns.checkip.html"
:delay 1
:local result [/file get dyndns.checkip.html contents]
# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local ipfresh [:pick $result $startLoc $endLoc]
:log info "DynDNS script: Internet IP = $ipfresh"
:if ($ipddns != $ipfresh) do={
:log info "DynDNS: Update IP needed, Sending UPDATE...!"
:local str "/nic/update?hostname=$ddnshost&myip=$ipfresh&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
/tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser \
password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
:delay 1
:local str [/file find name="DynDNS.$ddnshost"];
/file remove $str
:global ipddns $ipfresh
:log info "DynDNS script: IP updated to $ipfresh!"
} else={
:log info "DynDNS script: No changes";
}
}