Dynamic DNS Update Script for ChangeIP behind NAT - MikroTik Script RouterOS

This script is intended to update a ChangeIP.com Dynamic DNS account when your device is behind nat.

You need to set your username, password and hostname.

This was tested successfully on RouterOS 5.7

# Dynamic DNS for ChangeIP.com behind NAT
# Modified by Jorge Amaral, officelan.pt
# For support send mail to support at offficelan dot pt
#
# The original script was written by "webasdf" on the Mikrotik foruns, i just modified it to work with ChangeIP.com
#
# Here is where you need to set your definitions
:local user "user"
:local pass "pass"
:local host "host"
##############
##############
:global lastwanip;
:if ([ :typeof $lastwanip ] = "nothing" ) do={ :global lastwanip 0.0.0.0 };
:local wanip [:resolve $host];
:if ( $wanip != $lastwanip ) do={
	/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
	:local result [/file get dyndns.checkip.html contents]
	:local resultLen [:len $result]
	:local startLoc [:find $result ": " -1]
	:set startLoc ($startLoc + 2)
	:local endLoc [:find $result "" -1]
	:local currentIP [:pick $result $startLoc $endLoc]
	:set lastwanip $currentIP;
	:put [/tool dns-update name=$host address=$currentIP key-name=$user key=$pass ]
}
You may copy and paste the script below into the terminal window.

# oct/13/2011 00:51:52 by RouterOS 5.7
#
/system script
add name=DDNS policy=\
    ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
    source="# Dynamic DNS for ChangeIP.com behind NA\
    T\r\
    # Modified by Jorge Amaral, officelan.pt\r\
    # For support send mail to support at offficelan dot pt\r\
    #\r\
    # The original script was written by \"webasdf\" on the Mikrotik foruns, i just modified it to work with ChangeIP.com\r\
    #\r\
    # Here is where you need to set your definitions\r\
    :local user \"user\"\r\
    :local pass \"pass\"\r\
    :local host \"host\"\r\
    ##############\r\
    ##############\r\
    :global lastwanip;\r\
    :if ([ :typeof \$lastwanip ] = \"nothing\" ) do={ :global lastwanip 0.0.0.0 };\r\
    :local wanip [:resolve \$host];\r\
    :if ( \$wanip != \$lastwanip ) do={\r\
    \t/tool fetch mode=http address=\"checkip.dyndns.org\" src-path=\"/\" dst-path=\"/dyndns.checkip.html\"\r\
    \t:local result [/file get dyndns.checkip.html contents]\r\
    \t:local resultLen [:len \$result]\r\
    \t:local startLoc [:find \$result \": \" -1]\r\
    \t:set startLoc (\$startLoc + 2)\r\
    \t:local endLoc [:find \$result \"\" -1]\r\
    \t:local currentIP [:pick \$result \$startLoc \$endLoc]\r\
    \t:set lastwanip \$currentIP;\r\
    \t:put [/tool dns-update name=\$host address=\$currentIP key-name=\$user key=\$pass ]\r\
    }"
Credit: https://wiki.mikrotik.com