we use the dyndns service from http://www.no-ip.com on our behind nat Mikrotik Router distributed around Connectivia sites.
For this reason we delivered (tested on RouterOs 5.x) a new one script as a merge of the two faboulous scripts already available on wiki.mikrotik.com to have a dyndns update script
specific for No-IP dyndns service when Mkt devices are behind nat. Thanks to the creator of changeip script published on Wiki page http://wiki.mikrotik.com/wiki/Scripts- We hope it's no problem to use the base or some parts .
Here you have the script :
Code: Select all
#Dynamic DNS Update Script for No-IP DNS behind nat
# Set needed variables
:local username "uzername"
:local password "pazzword"
:local host "dreammachine.no-ip.org"
:global previousIP
# print some debug info
:log info ("Update No-IP DNS: username = $username")
:log info ("Update No-IP DNS: hostname = $host")
:log info ("Update No-IP DNS: previousIP = $previousIP")
#
# behind nat - get the publòic address using dyndns url http://checkip.dyndns.org
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
: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 currentIP [:pick $result $startLoc $endLoc]
:log info "No-IP DNS: currentIP = $currentIP"
:if ($currentIP != $previousIP) do={
:log info "No-IP: Current IP $currentIP is not equal to previous IP, update needed"
:set previousIP $currentIP
:local url "http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP&hostname=$host"
:log info "No-IP DNS: Sending update for $host"
/tool fetch url=$url user=$username password=$password mode=http dst-path=("no-ip_ddns_update.txt")
:log info "No-IP DNS: Host $host updated on No-IP with IP $currentIP"
}
else={
:log info "No-IP: update not needed "
}
# end