This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
networking:router:mikrotik_dyndns [2013/09/26 21:49] 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:// | + | ===== Mikrotik Cloud Method ===== |
- | http://forum.mikrotik.com/ | + | http://wiki.mikrotik.com/ |
- | | + | |
- | | + | |
- | :!: For some reason, this script wouldn't import via the CLI. I had to copy and paste it into Winbox | + | Dynamic DNS and NTP service that's simple |
- | < | + | To make a more memorable |
- | # Set needed variables | + | |
- | :local username " | + | |
- | :local password " | + | |
- | : | + | |
- | :global dyndnsForce "" | + | ==== Winbox ==== |
- | :global previousIP " | + | |
- | # print some debug info | + | **IP -> Cloud** |
- | :log info (" | + | |
- | :log info (" | + | |
- | :log info (" | + | |
- | :log info (" | + | |
- | # get the current IP address from the internet (in case of double-nat) | + | * Enable DDNS |
- | /tool fetch mode=http address=" | + | * Enable Update Time |
- | :delay 1 | + | |
- | :local result [/file get dyndns.checkip.html contents] | + | |
- | # parse the current IP result | + | ==== CLI ==== |
- | :local resultLen [:len $result] | + | |
- | :local startLoc [:find $result ": " -1] | + | |
- | :set startLoc ($startLoc + 2) | + | |
- | :local endLoc [:find $result "</ | + | |
- | :local currentIP [:pick $result $startLoc $endLoc] | + | |
- | :log info " | + | |
- | # Remove the # on next line to force an update every single time - useful for debugging, | + | < |
- | # but you could end up getting blacklisted by DynDNS! | + | /ip cloud set enabled=yes |
- | + | ||
- | #:set dyndnsForce true | + | |
- | + | ||
- | # Determine if dyndns | + | |
- | # more dyndns updater request details http:// | + | |
- | :if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={ | + | /ip cloud print |
- | :set dyndnsForce false | + | |
- | :set previousIP $currentIP | + | |
- | :log info " | + | |
- | /tool fetch user=$username password=$password mode=http address=" | + | |
- | src-path=" | + | |
- | dst-path="/ | + | |
- | :delay 1 | + | |
- | :local result [/file get dyndns.txt contents] | + | |
- | :log info (" | + | |
- | :log info (" | + | |
- | :put (" | + | |
- | #/tool e-mail send from=email@gmail.com server=173.194.77.108 to=me@gmail.com subject=" | + | |
- | #:log info "Email of new IP address sent" | + | |
- | } else={ | + | |
- | :log info (" | + | |
- | } | + | |
</ | </ |