User Tools

Site Tools


networking:router:mikrotik_dyndns

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
networking:router:mikrotik_dyndns [2013/09/27 22:24]
gcooper
networking:router:mikrotik_dyndns [2022/10/24 09:34] (current)
gcooper
Line 1: Line 1:
 ====== Mikrotik RouterOS Dynamic DNS ====== ====== Mikrotik RouterOS Dynamic DNS ======
  
-http://wiki.mikrotik.com/wiki/Scripts+===== Mikrotik Cloud Method =====
  
-http://forum.mikrotik.com/viewtopic.php?p=171805+http://wiki.mikrotik.com/wiki/Manual:IP/Cloud
  
-  - Add a script +  * Super simple to enable and no configuration required 
-  - Add a scheduler entry to run the script+  * Also supports NTP without configuring the SNTP Client
  
-===== Create a Script =====+Dynamic DNS and NTP service that's simple to set up and needs no scripts or scheduled tasks.  The only obvious down side is that the host name is not memorable.
  
-Copy and paste this script at the CLI to generate a script to be scheduled:+To make a more memorable hostname, you can create a CNAME record in another DNS domain name that you control using this DNS Name as the target.
  
-<file> +==== Winbox ====
-/system script add name=dyndns policy=+
- ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="\ +
- \n# Dynamic DNS Update Script\r\ +
- \n#\r\ +
- \n# Name resolution must be working.\r\ +
- \n#\r\ +
- \n# Set needed variables\r\ +
- \n:local username \"sonoracomm\"\r\ +
- \n:local password \"105700\"\r\ +
- \n:local hostname \"gcooper.dynalias.org\"\r\ +
- \n\r\ +
- \n:local dyndnsForce \"\"\r\ +
- \n:local previousIP [:resolve \$hostname]\r\ +
- \n\r\ +
- \n# print some debug info\r\ +
- \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\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-path=\"/dyndns.checkip.html\"\r\ +
- \n:delay 1\r\ +
- \n:local result [/file get dyndns.checkip.html contents]\r\ +
- \n\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 \"</body>\" -1]\r\ +
- \n:local currentIP [:pick \$result \$startLoc \$endLoc]\r\ +
- \n:log info \"UpdateDynDNS: currentIP = \$currentIP\"\r\ +
- \n\r\ +
- \n# Remove the # on next line to force an update every single time - useful for debugging,\r\ +
- \n# but you could end up getting blacklisted by DynDNS!\r\ +
- \n\r\ +
- \n#:set dyndnsForce true\r\ +
- \n\r\ +
- \n# Determine if dyndns update is needed\r\ +
- \n# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html\r\ +
- \n\r\ +
- \n:if ((\$currentIP != \$previousIP) || (\$dyndnsForce = true)) do={\r\ +
- \n:set dyndnsForce false\r\ +
- \n:set previousIP \$currentIP\r\ +
- \n\r\ +
- \n/tool fetch user=\$username password=\$password mode=http address=\"members.dyndns.org\" \\\r\ +
- \nsrc-path=\"nic/update\?system=dyndns&hostname=\$hostname&myip=\$currentIP&wildcard=no\" \\\r\ +
- \ndst-path=\"/dyndns.txt\"\r\ +
- \n:delay 1\r\ +
- \n:local result [/file get dyndns.txt contents]\r\ +
- \n:log info (\"UpdateDynDNS: Dyndns update needed\")\r\ +
- \n:log info (\"UpdateDynDNS: Dyndns Update Result: \".\$result)\r\ +
- \n:put (\"Dyndns Update Result: \".\$result)\r\ +
- \n#/tool e-mail send from=email@gmail.com server=173.194.77.108 to=me@gmail.com subject=\"Current IP is \$currentIP\"\r\ +
- \n#:log info \"Email of new IP address sent\"\r\ +
- \n} else={\r\ +
- \n:log info (\"UpdateDynDNS: No dyndns update needed\")\r\ +
- \n}" +
-</file>+
  
-===== Run the Script =====+**IP -> Cloud**
  
-<file> +  * Enable DDNS 
-/system script run dyndns +  * Enable Update Time 
-</file>+ 
 +==== CLI ====
  
-===== Create a Schedule ===== 
 <file> <file>
 +/ip cloud set enabled=yes update-time=yes
  
-/system scheduler add comment="Update DynDNS" disabled=no interval=10m name=dyndns \ +/ip cloud print
-  on-event=dyndns policy=reboot,read,write,policy,test,password,sniff,sensitive \ +
-  start-date=jan/01/1970 start-time=12:34:56;+
 </file> </file>
networking/router/mikrotik_dyndns.1380342273.txt.gz · Last modified: 2013/09/27 22:24 by gcooper