• Springs

    Pictures and screen shots Jim. This is the second time now!

    I think the format of what I sent with your “spin” on it is the way to go.

    • admin

      It’s on the list… getting the text done is less tedious than dealing with images…

  • Springs


    Use Netwatch.

    Use my runoce. Have netwatch enable it when the interface come up. Delay 00:01:00 then disable.


  • J.O.

    I had to add a # in front of a line to disregard it. Here is the line with the # added…
    # :log info “UpdateDynDNS: currentIP = $currentIP”

    I asked this question on IP and Jim helped me figure this out after comparing scripts.

  • Cory

    Well I can’t get it working but DynDNS has me confused, so it may be on the hostname isn’t setup correctly.

  • http://www.integrationpros.org/forums/showthread.php?21307-Springs-VS-Mikrotik!

    Post Number 2 contains the new update script.

    Jim pointed out a condition that could cause the old script to not update the actual dyndns records. In English… JIM BROKE SOMETHING! Then he pointed out… hey what if? Which is what led to the updated script. Props are in the script!

    Hopefully Jim will move it here ASAP.

    • admin

      Updated. Formatting is still a little off. Let me know if you have any trouble doing copy/paste from it.

  • cory

    I finally got my dyndns account up and working, confirmed, but this script still isn’t working. I’m guessing it is a formatting error???

    My script looks exactly as posted above, just replacing the red text in quotes, with my account info in quotes. Any ideas?

    • admin

      go in Terminal and do a /system script export and copy/paste that script here (but change your IP, login, password first…)

      • cory
        # dec/11/2012 15:25:49 by RouterOS 5.20
        # software id = UB2U-EHT1
        /system script
        add name=dyndns policy=\
            ftp,reboot,read,write,policy,test,winbox,password,sniff,api source=":delay\
            \n# Set needed variables\r\
            \n:local username \"myusername\"\r\
            \n:local password \"mypassword\"\r\
            \n:local hostname \"mydyndnshostaddress\"\r\
            \n:global systemname [/system identity get name]\r\
            \n:global dyndnsForce\r\
            \n:global previousIP\r\
            \n:local resolvedIP [:resolve \$hostname]\r\
            \n# print some debug info WHEN YOU F___ THIS UP... THIS WILL HELP YOU FIND\
            \n#:log info (\"UpdateDynDNS: username = \$username\")\r\
            \n#:log info (\"UpdateDynDNS: password = \$password\")\r\
            \n#:log info (\"UpdateDynDNS: hostname = \$hostname\")\r\
            \n#:log info (\"UpdateDynDNS: previousIP = \$previousIP\")\r\
            \n#:log info (\"UpdateDynDNS: resolvedIP = \$resolvedIP\")\r\
            \n# get the current IP address from the internet (in case of double-nat)\r\
            \n/tool fetch mode=http address=\"checkip.dyndns.org\" src-path=\"/\" dst-\
            \n:local result [/file get dyndns.checkip.html contents]\r\
            \n# parse the current IP result\r\
            \n:local resultLen [:len \$result]\r\
            \n:local startLoc [:find \$result \": \" -1]\r\
            \n:set startLoc (\$startLoc + 2)\r\
            \n:local endLoc [:find \$result \"\" -1]\r\
            \n:local currentIP [:pick \$result \$startLoc \$endLoc]\r\
            \n#:log info \"UpdateDynDNS: currentIP = \$currentIP\"\r\
            \n# Remove the # on next line to force an update every single time - usefu\
            l for debugging,\r\
            \n# but you could end up getting blacklisted by DynDNS!\r\
            \n#Edit: Not really needed anymore... the result is not equal... Update wi\
            ll happen.\r\
            \n#:set dyndnsForce true\r\
            \n# Determine if dyndns update is needed\r\
            \n# more dyndns updater request details http://www.dyndns.com/developers/s\
            \n#This is where we check the DNS record against actual result. Thanks to \
            \n:if ((\$currentIP != \$resolvedIP) || (\$dyndnsForce = true)) do={\r\
            \n:set dyndnsForce false\r\
            \n:set previousIP \$currentIP\r\
            \n/tool fetch user=\$username password=\$password mode=http address=\"memb\
            ers.dyndns.org\" \\\r\
            \nsrc-path=\"/nic/update\?hostname=\$hostname&myip=\$currentIP\" dst-path=\
            \n:local result [/file get dyndns.txt contents]\r\
            \n:log info (\"UpdateDynDNS: Dyndns update needed\")\r\
            \n:log info (\"Thanks Springs! Update Result: \".\$result)\r\
            \n:put (\"Dyndns Update Result: \".\$result)\r\
            \n} else={\r\
            \n:log info (\"UpdateDynDNS: No dyndns update needed\")\r\
        add name=update_ntp policy=\
            ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
            source=":delay 60s\r\
            \n/system ntp client set primary-ntp=[:resolve 0.pool.ntp.org]\r\
            \n/system ntp client set secondary-ntp=[:resolve 1.pool.ntp.org]"
        • admin

          are you entering the hostname like “jims.house.com” ?

          • cory

            Yes entering by just replacing the red text and keeping the quotes so and example would be:


            where “bdidns.com” is my registered dyndns zone and “coryshouse” would be the added host. I’ve confirmed the dyndns path is working via my mobile app for crestron. I have trippled checked the spelling for these three things.

          • admin

            Try running the script from terminal. Go to /system scripts, then type ‘print brief’. Each script has a number. Type ‘run 3’ if the dyndns script is number 3.
            It should kick back a syntax error if something is formatted wrong.
            Also, if you print your scripts from terminal it will highlight the first character of a word it doesn’t understand. It’s incredibly useful for troubleshooting.

          • cory

            Any other ideas? Does it all look right?

  • Springs

    The spacing is wrong if you cut and paste.

    :if (($currentIP != $resolvedIP) || ($dyndnsForce = true)) do={
    :set dyndnsForce false
    :set previousIP $currentIP
    /tool fetch user=$username password=$password mode=http address=”members.dyndns.org” \
    src-path=”/nic/update?hostname=$hostname&myip=$currentIP” dst-path=”/dyndns.txt”
    :local result [/file get dyndns.txt contents]
    :log info (“UpdateDynDNS: Dyndns update needed”)
    :log info (“Thanks Springs! Update Result: “.$result)
    :put (“Dyndns Update Result: “.$result)
    /ip firewall nat set [find comment~”FUCKUPDATE”] dst-address=”$previousIP”
    } else={
    :log info (“UpdateDynDNS: No dyndns update needed”)

  • Pingback: Hairpin NAT – or how to use your DynDNS address internally or externally | Networking For Integrators()

  • antonio

    I still have not tried the script, but I’m interested in installing 7 on my router, a question, but you might implement a notification email when changing or updating the ip

  • antonio

    I still have not tried the script, but I’m interested in installing 7 on my router, a question, but you might implement a notification email when changing or updating the ip

  • Doesn’t this line:
    :local endLoc [:find $result “” -1]

    needs to be change to this:
    :local endLoc [:find $result “” -1]

    • admin

      what is different between those two?

  • Don’t really know what the actual difference is Jim. I just started to read the whole Mikrotik thread at IP, but look at the post 61 on page 7 of that thread.


    • admin

      Good catch, Pedro! You’re right, the txt file was wrong – it had an HTML tag that got removed by WordPress. The rsc script file was correct the whole time. Actually it was the same problem they had on IP – the HTML tag didn’t show in the post.

      The txt file is updated now, good to go.

  • Jim on the explanation of how to implement the updater you have a section that reads:
    The third section to change is “:local hostname”. This is the URL you are assigning to your jobsite.

    I see global hostname and not local hostname . I think this was from an older version of the script.

  • OK, I’m having an issue trying to have this script in my router. If I drag and drop the rsc file created with Notepad into the files section the size of the file is 0 KB.
    If I try to create a new script, copy and paste the content of the text into the source window the script is not created, any ideas?

  • [MIKROTIK] Dynamic DNS Update Script for No-IP DNS

    Sumber: MR-EKOAPRIADI – http://www.mr-ekoapriadi.net/2013/08/mikrotik-dynamic-dns-update-script-for.html#ixzz2eky6HCeL

  • Cory

    I used the new RSC file to import and try this again. The first time I ran the script I got a new HTML file in the FILES section, but no text file. I went and ran again and nothing new. I tried using the Dropbox link to copy paste and redo the script, but now nothing new happens.

    I then deleted the HTML file that was created and ran again…still nothing.

    I re-imported the RSC file and ran the script and now nothing at all. No HTML and no Text file and no update according to my dyndns account.

    I compared the formatting and text to that of the dropbox linked text file and all looks the same.