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 22:22] 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/ |
- | | + | |
- | | + | |
- | ===== Script ===== | + | Dynamic DNS and NTP service that's simple to set up and needs no scripts or scheduled tasks. |
- | :!: For some reason, this script wouldn' | + | 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. |
- | < | + | ==== Winbox |
- | # dyndns.rsc | + | |
- | # | + | |
- | # Dynamic DNS Update Script | + | |
- | # | + | |
- | # Name resolution must be working. | + | |
- | # | + | |
- | # Set needed variables | + | |
- | :local username " | + | |
- | :local password " | + | |
- | :local hostname " | + | |
- | + | ||
- | :local dyndnsForce "" | + | |
- | :local previousIP [:resolve $hostname] | + | |
- | + | ||
- | # print some debug info | + | |
- | #:log info (" | + | |
- | #:log info (" | + | |
- | :log info (" | + | |
- | :log info (" | + | |
- | + | ||
- | # get the current IP address from the internet (in case of double-nat) | + | |
- | /tool fetch mode=http address=" | + | |
- | :delay 1 | + | |
- | :local result [/file get dyndns.checkip.html contents] | + | |
- | + | ||
- | # parse the current IP result | + | |
- | :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! | + | |
- | + | ||
- | #:set dyndnsForce true | + | |
- | # Determine if dyndns update is needed | + | **IP -> Cloud** |
- | # more dyndns updater request details http:// | + | |
- | :if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={ | + | * Enable DDNS |
- | :set dyndnsForce false | + | * Enable Update Time |
- | :set previousIP $currentIP | + | |
- | /tool fetch user=$username password=$password mode=http address=" | + | ==== CLI ==== |
- | 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 (" | + | |
- | } | + | |
- | </ | + | |
- | ===== Create a Schedule ===== | ||
< | < | ||
+ | /ip cloud set enabled=yes update-time=yes | ||
- | /system scheduler add comment=" | + | /ip cloud print |
- | on-event=dyndns policy=reboot, | + | |
- | start-date=jan/ | + | |
</ | </ |