You are on page 1of 1

In case of double NAT, you may use this script instead of the one above to detect IP address from

the internet. Note that you need to escape the special characters such as “ and $ and also to insert
the \r\ and \n line control characters.

# get the current IP address from the internet


/tool fetch mode=http address="checkip.dynu.com" src-path="/"
dst-path="/dynu.checkip.html"
:local result [/file get dynu.checkip.html contents]

# parse the current IP result


:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local currentIP [:pick $result $startLoc $resultLen]
:global ddnsuser your_Dynu_username
:global ddnspass "your_Dynu_password"
:global ddnshost "your_Dynu_hostname"
:global ipddns [:resolve $ddnshost];

#:global ipddns

:if ($ipddns != $currentIP) do={


:log info ("DynuDDNS: IP-Dynu = $ipddns")
:log info ("DynuDDNS: IP-Fresh = $currentIP")
:log info "DynuDDNS: Update IP needed, Sending UPDATE...!"
:global str "/nic/update?hostname=$ddnshost&myip=$currentIP"
:log info "currentIP is $currentIP"
/tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser
password=$ddnspass
dst-path=("/Dynu.".$ddnshost)
:delay 1
:global str [/file find name="Dynu.$ddnshost"];
/file remove $str
:global ipddns $currentIP
:log info "DynuDDNS: IP updated to $currentIP!"
} else={
:log info "DynuDDNS: No change needed";
}

You can verify that the script is added successfully by going to System then Scripts.

After verifying that the script is updating IP for your hostname properly, you can add a scheduler
entry to run the script every 5 minutes.

/system scheduler add comment="Update Dynu DDNS" interval=5m name=ddns_sheduller \


on-event="/system script run Dynu\r\n" policy=read,write,test start-time=startup

You might also like