How to do Dynamic DNS updating through DynDNS
Last updated: September 10, 2014 at 10:44 am – changed txt and rsc script links to Dropbox
Setting up DynDNS updating on a Mikrotik is a two-step process. Putting the Script into the router, and setting the Scheduler to run the script at timed intervals. The good thing is you have complete control over what the script is doing and when it is doing it. This is the reason we picked up Mikrotik in the first place. DynDNS updating wasn’t working correctly on other different routers and DVRs. I never saw any other consumer-grade router where you could even set the update interval. Consequently we had a lot of job sites that would lose connection until whenever the router/DVR decided to run another update. Not the case with Mikrotik.
First thing you should do is make sure you are logged in with a permanent login. If you are logged in as ‘admin’ and you plan on changing your login to something else and deleting/disabling the ‘admin’ login, do that first. The script sets up variables that are saved internally and assigns your current login as the ‘owner’. If the owner of the script and variables are ‘admin’ and you delete the ‘admin’ login… you could have problems down the road. I now change my login before I do anything else in the router. Add your login and password, exit Winbox, log in with your new credentials. Delete the ‘admin’ user if you want to. (I always do…)
Go to System / Scripts. Add a new Script. Name it something simple like “dyndns”. You will refer to the name of the script when you set it to run in the Scheduler.
Copy and paste this text file into the Source text box:
Or import this into an .rsc file and it will set up the script at 10 minute scheduler for you (download, make sure it gets saved with rsc file extension, read how to import an rsc file):
Your DynDNS login, password, and hostname
You need to enter your login and password in the “:local username” and “:local password” sections. This is the exact same login you use to get into your DynDNS account at www.dyndns.com. It’s important to note that if you ever change your password on DynDNS’s site you will have to go back through ALL your jobsites that use DynDNS updating. This isn’t a Mikrotik thing, it’s just how DynDNS works. So pick a good password and stick with it.
The third section to change is “:local hostname”. This is the URL you are assigning to your jobsite. For us, we use customername.ourcompanyname.net. Whatever it is that you are using goes in here. Do NOT enter the “http://”. It’s not needed. You have to have the URL set up through DynDNS before you run this script, so go ahead and get that done…
Testing it for the first time
You definitely want to test the script first. There could be a formatting error you missed that becomes a bear to track down later. From the Script window where you pasted the text, click Run Script. Now if you go to the Files window, you should see a new file called dyndns.txt. If this file is there then your script is working. If not, go back and check your script formatting, your login and password, and that your URL is correct. Go back and click Run Script again. This time another new file should appear, called dyndns.checkip.html. You can also check your DynDNS account and see that your new URL was just updated at the time and date that you clicked the Run Script button.
Now that you have a working DynDNS updater…
… you need to tell the router when you want it to update. Right now you just have a script. It only runs when you click Run Script. Nothing else is telling that script to run.
Go to System / Scheduler and add a new Schedule. Name it something simple like “DDNS updater”. Click on Start Time and select startup. Go to Interval and change it to 00:10:00. (In Mikrotik-speak, that formatting always means hours:minutes:seconds.) That will make the router run your script every 10 minutes.
Go to the On Event box and type the exact name of the script you created. If you named it dyndns, then just enter dyndns and nothing else.
Hit OK or Apply. You can see the Run Count and the next scheduled event time from the Scheduler window. It should now read 10 minutes from when you clicked OK or Apply.
Do not set the Interval to less than 10 minutes!
If you do, you will be violating DynDNS’s Terms of Service and they can blacklist you. If that happens, all those jobsites you set up will stop updating… You don’t want that.