Last Updated on November 28, 2014 EST by Jordan
This is a script for ensuring that your DynDNS hostname is updated when your IP changes on your MikroTik router. Unfortunately the script from the MikroTik Wiki doesn’t work and is broken.
http://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_dynDNS
- There is a question mark within the URL that posts the update to members.dyndns.org and it gets removed when you paste and run the code through telnet/ssh. To fix it you will need to put a slash in-front of the question mark for it to be passed correctly.
This script is now on GitHub at https://github.com/jordantrizz/mikrotik-scripts/blob/master/dyn-dns
# Set needed variables
:local username "username"
:local password "password"
:local hostname "hostname"
:global dyndnsForce
:global previousIP
# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
# 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 "