DDNS script for *.sn.mynetname.net with WAN interface behind NAT

#get mynetname hostname
:local hostname [/ip cloud get dns-name]

#resolve current dns-address
:local resolvedIP [:resolve "$hostname"]

#get current external IP
:local resolver [:resolve resolver1.opendns.com]
:local currentIP [:resolve myip.opendns.com server=$resolver]

#determine if DNS update is needed
:if ($currentIP != $resolvedIP) do={
   :log info ("Mynetname update needed: Current-IP: $currentIP Resolved-IP: $resolvedIP")
   /ip cloud force-update
} else={
   :log info ("Mynetname: No update needed ($currentIP=$resolvedIP)")
}

#schedule script every 5 minutes or so
#special thanks to thiagomedeiros for the trick with opendns

Hi
Great script.
Thank you

Great, thank you

You don’t need to fetch a file, replace this:

#get current external IP
tool fetch mode=http url="http://myip.dnsomatic.com/mypublicip.txt"
:delay 1
:local currentIP [/file get mypublicip.txt contents ]
/file remove "mypublicip.txt"

To this:

:global currentIP [:resolve myip.opendns.com server=208.67.222.222];

Will always return your public IP. Not needed to download/fetch a file.
Work in NAT too.

Great script, Thanks!

Wonderful, I hated the fetch-file-part. Especially because i couldn`t get rid of the log entry produced by that!
Thank you!

Thanks for sharing..
It works with my rb750g which is for load balancing but with the main router i can ping the DNS Name but i can’t connect to it with winbox !! any suggestion ?

thanks very much !