An alternate to changeip.com (free ddns) .
From few days , we were having issues in updating our mikrotik/linux base machines dynamic ip to free DDNS service like changeip.com, therefore today I tested DYNU as an alternate and it worked very good. we can use it as backup or primary ddns service for our mikrotik routers.
First create account at http://www.dynu.com, add your required host. and then add script and schedule it to run after every 5 (or xx) minutes
Mikrotik Script for Dynu ddns.
The below script is working 100% on Mikrotik 5.x and 6.x versions.
[Tested as of now / 1st-DEC-2015]
(You can copy paste following code in mikrotik by going to SYSTEMS / SCRIPTS / CLICK ON + sign to add script, and paste following.
NOTE: MAKE SURE YOU CHANGE THE REQUIRED FIELDS BEFORE DEPLOYMENT.
SCRIPT NAME: “DYNU“
1- SCRIPT FOR DSL MODEM IN BRIDGE MODE, MIKROTIK HAVE THE PUBLIC IP ADDRESS AT WAN INTERFACE.
(FOR BRIDGE MODE, PUBLIC IP IS DIRECTLY ON MIKROTIK WAN INTERFACE)
NOTE: If you have multiple IP address configured on WAN interface, it will give you error of “Invalid internal item number”
############################################## # DYNU SCRIPT for Mikrotik , DSL Modem BRIDGE MODE, # Wan dialing is done by mikrotik so public ip is on mikrotik directly # CHANGE THE FOLLOWING ACCORDING TO YOUR CREDENTIALS # Syed Jahanzaib / aacable at hotmail dot com # #################################################### :global ddnsuser DYNU_USER :global ddnspass "DYNU_PASSWORD" :global theinterface "WAN_INTERFACE_NAME" :global ddnshost "YOUR_DYNU_HOSTNAME.dynu.com" #### Donot change below this line #### :global ipddns [:resolve $ddnshost]; :global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ] :if ([ :typeof $ipfresh ] = nil ) do={ :log info ("DynuDDNS: No IP address on $theinterface .") } else={ :for i from=( [:len $ipfresh] - 1) to=0 do={ :if ( [:pick $ipfresh $i] = "/") do={ :set ipfresh [:pick $ipfresh 0 $i]; } } :if ($ipddns != $ipfresh) do={ :log info ("DynuDDNS: IP-Dynu = $ipddns") :log info ("DynuDDNS: IP-Fresh = $ipfresh") :log info "DynuDDNS: Update IP needed, Sending UPDATE...!" :global str "/nic/update?hostname=$ddnshost&myip=$ipfresh" /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 $ipfresh :log info "DynuDDNS: IP updated to $ipfresh!" } else={ :log info "DynuDDNS: dont need changes"; } }
Now run it and watch the results.
2- SECOND SCRIPT FOR DSL MODE, MIKROTIK IS CONNECTED TO INTERNET BEHIND DSL. (NAT)
######################################## # DYNU DNS Script for Mikrotik Behind DSL # 14th JAN-2015 # Syed Jahanzaib / aacable at hotmail dot com # #################################################### # get the current IP address from the internet (in case of double-nat) /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 "" -1] :local currentIP [:pick $result $startLoc $endLoc] #:log warning "UpdateDynDNS: currentIP = $currentIP" ###################################################### :global ddnsuser DNSUSERNAME :global ddnspass "DNSPASSWORD" :global ddnshost "YOURHOST.dynu.com" :global ipddns [:resolve $ddnshost]; #:global ipddns 1.2.3.4 :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" /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: dont need changes"; } }
To scheudle it to run every 5 minutes , use
/system scheduler add disabled=no interval=5m name=dynu on-event=dynu policy=\ ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api start-date=jan/01/1970 \ start-time=00:00:00
Regard’s
Syed Jahanzaib