Page 1 of 1

DynDNS Script from Mikrotik Wiki (correction)

Posted: Sun Apr 05, 2020 1:58 pm
by candrian
Hi all,

I'm new to Mikrotik. I just bought the HAP AC2 and i'm on the configuration period. I have set this router as the main router of my home network which also connects to the internet via PPPoE through the ISP modem. I have also set up Pi-Hole as the local DNS. While i was trying to find a script for updating my DynDNS domain i found in the official wiki a page with a script for this purpose. https://wiki.mikrotik.com/wiki/Dynamic_ ... _No-IP_DNS. I tried the script several times with no success but after some debugging i noticed that firstly, the router couldn't resolve the domain (http://dynupdate.no-ip.com/) so i found out that the user must have set a DNS IP address under IP->DNS->Servers (maybe this must only be set up in the case you are using a local DNS as i do) and the second one was that the $previousIP variable in the script it seemed that on each run didn't have the previous value. So i noticed here that the suggested permissions write, test, read wasn't enough for the global variable to be set. So i granted policy permissions also and now everything works.

If the $previousIP is not set then on each run the script will send an ip update request to the DynDNS server even when the ip has not be changed (this is only noticeable though the logs. Otherwise the user is not affected)

So these two are suggestions if you are interested to be added in your official wiki page.

Thanks,
Haris

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Mon Apr 06, 2020 12:12 pm
by Jotne
You can use MikroTik Colud DNS, its free. Then you can point your dyndns to the MikroTiok clod DNS name. (if its possible)
Or drop dyndns and only use Mikrotik Cloud DNS as your public DNS name.

IP->Cloud [x] DDNS Enable.
Then you should get a fixed DNS name like this:

PublicIP: 65.232.13.123 (your outside IP)
DNS Name: 6f3806exxxxx.sn.mynetname.net (Serial number your router + .sn.mynetname.net)

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sat Apr 11, 2020 1:44 pm
by aceror
Hello
Make script call DynDns and paste this

# 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")
}

then run this in command
/system scheduler
add interval=1m name=DynDns on-event=DynDns policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api start-time=startup

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sun Apr 12, 2020 12:32 pm
by Jotne
Thanks for the script.
Use code tags. Select text and click the </> button.

Like this: (with tabs as well)
# 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")
	}

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sat Feb 20, 2021 5:57 pm
by tuxedo21
hi I am new here, I got software routeros 4.86.1 and in my IP section, I did not see "IP cloud" feature in the list , I like to use my dynamic service with dyndns, can anyone can help me to get this feature back to IP section ?

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Tue Feb 23, 2021 11:19 am
by Jotne
I guess, you have 6.48.1 and Cloud should be there.

In Winbox (3.27) it looks like this:
cloud.jpg
cloud.jpg

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Tue Mar 02, 2021 7:09 am
by texmeshtexas
I noticed that if I changed the IP in my dyndns.org account. This script would not correct it.
To fix that, I made these changes.

:local dyndnsForce
:local previousIP [resolve $hostname]

Now the script truly compares the routes current IP with that resolved by $hostname

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Fri Jan 14, 2022 9:53 am
by imamic
Hi guys,

Thanks for the script, it works. How to hide credentials in LOG file?
Every minute he sends user/pass/hostname to log file.

Thanks for the help

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Fri Jan 14, 2022 1:16 pm
by Jotne
Remove one or all of these lines:
# print some debug info
	:log info ("UpdateDynDNS: username = $username")
	:log info ("UpdateDynDNS: password = $password")
	:log info ("UpdateDynDNS: hostname = $hostname")
	:log info ("UpdateDynDNS: previousIP = $previousIP")

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Fri Jan 14, 2022 2:23 pm
by imamic
Great!

Thanks for your selfless help :)

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sun Jun 26, 2022 11:55 am
by knifehandz
Just came across this and the script is really helpful!

Would like to share a modified version that uses the new API (using Client Update Key) and gives a warning if forced update is turned on in case anyone is interested.

Tested with RouterOS 7.2.3
# 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")
	}

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Thu Nov 23, 2023 11:09 am
by imamic
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.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Mon Dec 18, 2023 3:49 pm
by maxb
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.
I'm facing this exact same problem.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Thu Dec 21, 2023 9:49 am
by nbajkovec
I'm facing the same issue, worked fine untill update to 7.11.2 version. Has anyone found a solution for the problem?

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Fri Dec 22, 2023 12:31 pm
by Patty
Hey, sorry for my possibly bad English, I use a translator.
I did the update to 7.13 yesterday and also had problems with the script execution for dyndns.
I was able to solve the problem by activating "FTP" in the script.
Problem.png
Solution.png
I hope that this is perhaps also your problem and can be remedied.

Greetings Patty

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sat Dec 23, 2023 10:44 pm
by Benqer
With "ftp" the script don't work too, but only for IPv6.
IPv4 works fine.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sun Dec 24, 2023 6:28 am
by qatar2022
I'm facing this exact same problem.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Tue Dec 26, 2023 1:00 pm
by macobi
im facing the same issue.

any solutions already available?

got ROS 7.13 running and got a dyndns account

thx and BR

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Fri Dec 29, 2023 8:46 pm
by Kobold81
I face the same problem, thought that was my misonfiguration.

[/ip address get [find where interface=$theinterface] value-name=address] does also not show my current ip.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sat Dec 30, 2023 1:35 pm
by rextended
Interface can have multiple addresses, so the script is bad at the start...

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sat Dec 30, 2023 2:45 pm
by Kobold81
Your statement is correct, but the cli command does not return any address. If it would return multiple, I could select the correct one (in this use case that would be strange) . But it returns nothing for any interface. It did work until 7.12

So the questions is: what is the solution....

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sun Dec 31, 2023 1:07 pm
by diamuxin
With the latest versions of RouterOS the "fetch" command does not work https anymore.

Image

Try this: (Something similar happened to me with a script)
/tool fetch mode=https \

# change to:

/tool fetch mode=http \

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sun Dec 31, 2023 3:08 pm
by macobi
Hi folks,

looks like that Router OS 7.14beta4 fixes that bug:

https://mikrotik.com/download/changelog ... lease-tree

anybody already able to test?

BR and happy new year to all

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sun Dec 31, 2023 6:04 pm
by rextended
With the latest versions of RouterOS the "fetch" command does not work https anymore.
False... and define what is "latest versions" for you.

7.13 terminal code

[vmtest@] > :put ([/tool fetch url="https://upgrade.mikrotik.com/routeros/NEWESTa7.stable" as-value output=user]->"data")
7.13 1702545848

The script is bad implemented at the start, if it just download from one "url" is not needed any mode/src/etc. frills

And at the time I write, https://checkip.dyndns.org/ do not work at all, not even on other systems

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Sun Dec 31, 2023 7:44 pm
by anav
Kitty has claws, do not mess with it, even with only one eye open you will get hurt, thinking your script knowledge is somehow better, such a comedian. You do know that cat is just Yoda in disguise.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Mon Jan 01, 2024 1:07 pm
by diamuxin
False... and define what is "latest versions" for you.
uff I can't get used to those manners ;-) but I like him...

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.
*) fetch - fixed fetch when using "src-path" with HTTP/HTTPS modes (introduced in v7.13);
Happy new year and please, it doesn't cost work to be a little kind.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Mon Jan 01, 2024 1:47 pm
by rextended
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.
It probably depends on the fact that I am NOT a native English speaker and I don't use automatic translators... :lol: At least if I make a mistake it's my fault...
And in any case, whether or not it seems like an offense, at least compared to others (not present in this topic so far) at least I try to explain my reasons...


it doesn't cost work to be a little kind
Please try to understand my previous sentences...

Happy Birthday to You too! And to the Others!

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Mon Jan 01, 2024 10:12 pm
by optio
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.
*) fetch - fixed fetch when using "src-path" with HTTP/HTTPS modes (introduced in v7.13);
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.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Tue Jan 23, 2024 1:01 pm
by tdeak
This is a tested and working script if anyone looking for a solution:

Tested on Mikrotik RouterOS: 7.12.1
# 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")
	}
 

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Tue Mar 26, 2024 5:15 am
by tareqbd
Thanks for the script.
Use code tags. Select text and click the </> button.

Like this: (with tabs as well)
# 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")
	}
I have two nic(S)/WAN. how can i define failover nic in this script?

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Mon Apr 22, 2024 4:36 pm
by kriszy
Hi there, quite new to Mikrotik. Tried utilizing tdeak's script but for some reason the new IP does not get updated on dyndns side, at the end of the log I get this error code:

"...to dyndns.txt FAILED: Fetch failed with status 400"

Not sure if anyone can help. I am on ROS 7.13. Tried interchanging https with http with fetch tool to no avail, still keep getting the same error.
Thank you ever so much for any advise.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Wed Jul 10, 2024 11:37 am
by phooo
Hi, I want to do AutoUpdate Port Forwarding IP Public Dynamic (dyndns.com) with Mikrotik.

Does anyone have the script?

I did WebManage 3CX PBX IP port forwarding, but Destination-Address (dst-address) cannot autoupdate public ip from DialUp PPPoE.
NB: i am using RB750 V.6.49.15

Thank you very much for your advice.

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Fri Aug 09, 2024 7:04 pm
by bigsrlcuneo
Hi everyone
We have multiple customer installation with mikrotik's router and an dynamic host on its public IP; mikrotik should update the host using DYNDNS services.
We used the "first version" of the script, this:
# 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")
}
for a long time it works great, but now are experiencing problems; in the log files we can see errors:

Image

So we just tried to use the new script:

# 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")
	}

but also this script log some errors:

Image

the most strange things is that sometimes works, and sometimes not...We are using ROS 7.15.3 in all devices; does anyone have an a idea how to solve this?
Thanks
bye

Re: DynDNS Script from Mikrotik Wiki (correction)

Posted: Mon Aug 19, 2024 4:51 pm
by bigsrlcuneo
Please, someone can help us?