DDNS.org - Mikrotik configuration


This dynDNS configuration applies to:
Brand Mirkotik
Model All Models
Official Website https://mikrotik.com/
Configuration to use Provided Script

DDNS.ORG MIkrotik configuration

{primary} To configure a Mikrotik router with DDNS.org service you should use the provided script and set a cron job that calls the script.

  • Step 1

    Connect to the router using a Terminal (like puTTY) or Winbox software.

  • Step 2

    Substitute in the following script your values for YOURUSERNAME, YOURPASSWORD, YOURHOSTNAME getting the values from your ddns.org account

# Set the following values from your ddns.org account https;//ddns.org/dashboard/configuration
    :local username "YOURUSERNAME"
    :local password "YOURPASSWORD"
    :local hostname "YOURHOSTNAME"

## no need to modify after this line.

    :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.it" src-path="/" dst-path="/dyndns.checkip.html"
    :delay 1
    :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

    :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="update.ddns.org" \
        src-path="nic/update?hostname=$hostname&myip=$currentIP" \
        dst-path="/dyndns.txt"
        :delay 1
        :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")
    }

If you use Winbox

Paste the script using the menu System->Script

If you use a Terminal

You should first create a new system script using the following commands:

/system script
add name=DDNS
policy=read,write,test

and then paste the script.

  • Step 3

    Add a scheduler that calls the script every 5 minutes to send an update when IP changes.

/system scheduler add comment="Update DDNS" interval=5m name=ddns_sheduller \
on-event="/system script run DDNS\r\n" policy=read,write,test start-time=startup  

Conclusion

If have doubts or problems configuring the mikrotik router with DDNS.org you can check the Troubleshooting page or contact the support from your account using the Support Request form.