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 [2015/01/10 21:40]
gcooper
networking:router:mikrotik_dyndns [2022/10/24 09:34] (current)
gcooper
Line 2: Line 2:
  
 ===== Mikrotik Cloud Method ===== ===== Mikrotik Cloud Method =====
 +
 +http://wiki.mikrotik.com/wiki/Manual:IP/Cloud
  
   * Super simple to enable and no configuration required   * Super simple to enable and no configuration required
Line 10: Line 12:
 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. 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 ====
-/ip cloud set enabled=yes update-time=yes+
  
-/ip cloud print +**IP -Cloud**
-</file>+
  
-===== Script Method =====+  * Enable DDNS 
 +  * Enable Update Time
  
-http://wiki.mikrotik.com/wiki/Scripts +==== CLI ====
- +
-http://forum.mikrotik.com/viewtopic.php?p=171805 +
- +
-  - Add a script +
-  - Add a scheduler entry to run the script +
- +
-Copy and paste this script at the CLI to generate a script to be scheduled:+
  
 <file> <file>
-/system script add name=dyndns policy=\ +/ip cloud set enabled=yes update-time=yes
- 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 \"dyndnsuser\"\r\ +
- \n:local password \"dyndnspass\"\r\ +
- \n:local hostname \"dyn,dns.hostname\"\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 print
- +
-<file> +
-/system script run dyndns +
-</file> +
- +
-===== Create a Schedule ===== +
-<file> +
- +
-/system scheduler add comment="Update DynDNS" disabled=no interval=10m name=dyndns \ +
-  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.1420951235.txt.gz · Last modified: 2015/01/10 21:40 by gcooper