MikroTik – DynDNS Update Script

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.


  • 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 "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"

# Remove the # on next line to force an update every single time - useful for debugging,
# but you could end up getting blacklisted by DynDNS!

#:set dyndnsForce true

# Determine if dyndns update is needed
# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html

:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
   :set dyndnsForce false
   :set previousIP $currentIP
   :log info "$currentIP or $previousIP"
   /tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
      src-path="/nic/update\?hostname=$hostname&myip=$currentIP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" \
   :local result [/file get dyndns.txt contents]
   :log info ("UpdateDynDNS: Dyndns update needed")
   :log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
   :put ("Dyndns Update Result: ".$result)
} else={
   :log info ("UpdateDynDNS: No dyndns update needed")
You May Also Like

Want a Google Reader equivalent, then check out Tiny Tiny RSS 1.2.12

When I firsted looked at the this application, I thought it was going to look ugly and have no functionallity. I mean after looking at Google Reader and using it for some time, it really was another good Google Application. And it was made to make it easy to read and sort RSS feeds. One look at the demo, and I was hooked. It has some common features that Google Reader does, starred items and labels. I just wonder if you can plop and authentication/user account creation on it so that you can offer your own branded reader similar to Googles. TinyTiny RSS 1.2.12 Demo!
Tiny Tiny RSS 1.2.12 (Default branch) - Screenshot Tiny Tiny RSS is a Web-based news (RSS, RDF, or Atom) feed aggregator designed to allow you to read news from any location, while feeling as close to a real desktop application as possible.
License: GNU General Public License (GPL)
This release fixes reported bugs, adds the zh_CN translation, and adds various minor improvements.