# Set needed variables
:local username "YOURUSERNAME"
:local password "YOURPASSWORD"
:local hostname "YOURHOSTNAME.dyndns.org"
:global dyndnsForce
:global previousIP
# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
: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 "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"
# 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
# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
:log info "$currentIP or $previousIP"
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no" \
dst-path="/dyndns.txt"
:delay 1
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}
# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
# Set needed variables
:local username "DYN_USER_NAME"
:local clientkey "DYN_CLIENT_KEY"
:local hostname "HOST_TO_UPDATE"
:global dyndnsForce
:global previousIP
# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
: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 "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"
# 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
# more dyndns updater request details https://help.dyn.com/remote-access-api/perform-update/
:log info "UpdateDynDNS: previousIP = $previousIP"
:if ($dyndnsForce = true) do={ :log warning "UpdateDynDNS: Forced update on" }
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch mode=https \
url="https://$username:$clientkey@members.dyndns.org/v3/update?hostname=$hostname&myip=$currentIP" \
dst-path="/dyndns.txt"
:delay 1
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}
I'm facing this exact same problem.Hi everyone,
I'm currently facing an issue with my MikroTik router after updating the firmware to version 7.12.1 a few days ago. I'm using the latest script with a DNS client key, and since the update, the DynDNS is not updating correctly.
The strange part is that the router indicates a successful update, showing the new IP, but when I check on the DynDNS website, the new IP is not assigned. I've already tried generating a new key, but unfortunately, that didn't resolve the issue.
I'm reaching out to the community to see if anyone else is experiencing similar problems or has any insights into resolving this issue. Could it be a problem on the DynDNS side, or is there something specific to the MikroTik FW 7.12.1 update that might be causing this discrepancy?
I appreciate any assistance or advice you can provide.
Thank you in advance for your help.
/tool fetch mode=https \
# change to:
/tool fetch mode=http \
False... and define what is "latest versions" for you.With the latest versions of RouterOS the "fetch" command does not work https anymore.
[vmtest@] > :put ([/tool fetch url="https://upgrade.mikrotik.com/routeros/NEWESTa7.stable" as-value output=user]->"data") 7.13 1702545848
uff I can't get used to those manners but I like him...False... and define what is "latest versions" for you.
*) fetch - fixed fetch when using "src-path" with HTTP/HTTPS modes (introduced in v7.13);
It probably depends on the fact that I am NOT a native English speaker and I don't use automatic translators... At least if I make a mistake it's my fault...uff I can't get used to those manners but I like him...
Happy new year and please, it doesn't cost work to be a little kind.
Please try to understand my previous sentences...it doesn't cost work to be a little kind
Why use mode or any other param that is part of url like address, port and src-path for http(s) fetch? Url as single argument is enough, url schema sets mode if not set and other params are all part of url.My answer is based on my own experience (when switching to 7.13) and that's why I wanted to help, nothing more. At the time it didn't work with "mode=https" and switching to http fixed it. Now users report that with the latest beta it is fixed.
Code: Select all*) fetch - fixed fetch when using "src-path" with HTTP/HTTPS modes (introduced in v7.13);
# Set needed variables
:global username "your-login-name"
:global password "your-password"
:global hostname "your-dyndns"
:global dyndnsForce
:global previousIP
# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
: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 "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"
# 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
# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
:log info "$currentIP or $previousIP"
/tool fetch user=$username password=$password mode=https address="members.dyndns.org" \
src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no" \
dst-path="/dyndns.txt"
:delay 1
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}
I have two nic(S)/WAN. how can i define failover nic in this script?Thanks for the script.
Use code tags. Select text and click the </> button.
Like this: (with tabs as well)
Code: Select all# Set needed variables :local username "YOURUSERNAME" :local password "YOURPASSWORD" :local hostname "YOURHOSTNAME.dyndns.org" :global dyndnsForce :global previousIP # print some debug info :log info ("UpdateDynDNS: username = $username") :log info ("UpdateDynDNS: password = $password") :log info ("UpdateDynDNS: hostname = $hostname") :log info ("UpdateDynDNS: previousIP = $previousIP") # get the current IP address from the internet (in case of double-nat) /tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html" :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 "</body>" -1] :local currentIP [:pick $result $startLoc $endLoc] :log info "UpdateDynDNS: currentIP = $currentIP" # 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 # more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html :if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={ :set dyndnsForce false :set previousIP $currentIP :log info "$currentIP or $previousIP" /tool fetch user=$username password=$password mode=http address="members.dyndns.org" \ src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no" \ dst-path="/dyndns.txt" :delay 1 :local result [/file get dyndns.txt contents] :log info ("UpdateDynDNS: Dyndns update needed") :log info ("UpdateDynDNS: Dyndns Update Result: ".$result) :put ("Dyndns Update Result: ".$result) } else={ :log info ("UpdateDynDNS: No dyndns update needed") }
# Set needed variables
:local username "user"
:local password "password"
:local hostname "host"
:global dyndnsForce
:global previousIP
# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
: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 "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"
# 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
# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
:log info "$currentIP or $previousIP"
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no" \
dst-path="/dyndns.txt"
:delay 1
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}
# Set needed variables
:global username "your-login-name"
:global password "your-password"
:global hostname "your-dyndns"
:global dyndnsForce
:global previousIP
# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
: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 "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"
# 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
# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
:log info "$currentIP or $previousIP"
/tool fetch user=$username password=$password mode=https address="members.dyndns.org" \
src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no" \
dst-path="/dyndns.txt"
:delay 1
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}