Community discussions

 
NevOZ
just joined
Topic Author
Posts: 6
Joined: Thu Jul 21, 2011 2:15 am

DuckDNS Update Script (free DynDNS alternative)

Fri Apr 18, 2014 3:10 am

Hello All,

As many of you know, DynDNS will cease to have free dynamic DNS services within a month's time.

As a result, I will be using one of the alternative free services instead - DuckDNS ( https://duckdns.org/ ) , and thought I'd share my script.

This script runs differently to almost all other Mikrotik dynamic DNS update scripts I have found on the Net. The usual method is to have the script run at intervals. Whereas my script runs all the time, monitors the WAN connection, and detects if the IP address changes. Not saying this is a better way, it is just the way I have done it.
So therefore, when setting it up in the Mikrotik scheduler, set it to run at startup only.

All you need to change in the script below is the "exampledomain" and the token.

Hope it's handy for someone.

Nev

ros code

/ interface pppoe-client {
	:global ExternalIP
	:local clientip
	:local clientstatus
	:while (1 < 2) do={
		monitor pppoe-out1 once do={:set clientip $"local-address"; :set clientstatus $status}
		:if ($clientstatus="connected" and $ExternalIP!=$clientip) do={
			:delay 1  
			:log info "UpdateDuckDNS: IP change detected - $ExternalIP to $clientip. Updating Duck DNS."
			/tool fetch mode=https url="https://www.duckdns.org/update?domains= ... =$clientip" dst-path=duckdns.txt;
			:delay 1
			:local result [/file get duckdns.txt contents]
			:log info "UpdateDuckDNS: Duck DNS update result: $result";
			:set ExternalIP $clientip
		}
		:delay 5
		}
}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2932
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: DuckDNS Update Script (free DynDNS alternative)

Fri Apr 18, 2014 6:15 am

LogMeIn & DynDNS : two example of business.

Do not help anyone to make and grow free service, when you have debugged "all the problem" and the program is near vital to you, the program end Free support, on 30 days... or 7 days only...

Very ransom example....

There are also many service like this two on the years...

Do not base your works on free product,
not be blind on Open source project. Not all bug discovered, because free code, are reported...
I'm Italian, not English. Sorry for my imperfect grammar.
 
NevOZ
just joined
Topic Author
Posts: 6
Joined: Thu Jul 21, 2011 2:15 am

Re: DuckDNS Update Script (free DynDNS alternative)

Fri Apr 18, 2014 7:16 am

...when you have debugged "all the problem" and the program is near vital to you...
7 days I agree is too soon to allow users to transition, but if the service is "vital", then it is probably worth paying for. Just remember that what they are providing does cost them money.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2932
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: DuckDNS Update Script (free DynDNS alternative)

Fri Apr 18, 2014 10:46 am

...when you have debugged "all the problem" and the program is near vital to you...
7 days I agree is too soon to allow users to transition, but if the service is "vital", then it is probably worth paying for. Just remember that what they are providing does cost them money.
Yes, ok, cost money, but is no reasonable only 7 days for migration of 40 machine.
This is a ransom....
I'm Italian, not English. Sorry for my imperfect grammar.
 
NevOZ
just joined
Topic Author
Posts: 6
Joined: Thu Jul 21, 2011 2:15 am

Re: DuckDNS Update Script (free DynDNS alternative)

Sat Apr 19, 2014 2:44 am

40 machines? If you are saying there are 40 different hostnames then you are violating the DynDNS free account terms anyway. You are only permitted to have 1 free account, and each account only allows 1 or 2 hostnames I believe.

Yes, ok, cost money, but is no reasonable only 7 days for migration of 40 machine.
This is a ransom....
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2932
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: DuckDNS Update Script (free DynDNS alternative)

Sat Apr 19, 2014 10:08 am

Yes, ok, cost money, but is no reasonable only 7 days for migration of 40 machine.
This is a ransom....
40 machines? If you are saying there are 40 different hostnames then you are violating the DynDNS free account terms anyway. You are only permitted to have 1 free account, and each account only allows 1 or 2 hostnames I believe.
I'm talk about LogMeIn, not DynDNS.
I'm Italian, not English. Sorry for my imperfect grammar.
 
User avatar
THG
Member
Member
Posts: 472
Joined: Thu Oct 15, 2009 1:05 am

Re: DuckDNS Update Script (free DynDNS alternative)

Sun Apr 20, 2014 10:20 pm

This script runs differently to almost all other Mikrotik dynamic DNS update scripts I have found on the Net. The usual method is to have the script run at intervals. Whereas my script runs all the time, monitors the WAN connection, and detects if the IP address changes. Not saying this is a better way, it is just the way I have done it.
So therefore, when setting it up in the Mikrotik scheduler, set it to run at startup only.
This script will only work with a PPPoE connection. If you have the energy, please make a script that works with ethernet.

Thanks
 
NevOZ
just joined
Topic Author
Posts: 6
Joined: Thu Jul 21, 2011 2:15 am

Re: DuckDNS Update Script (free DynDNS alternative)

Mon Apr 21, 2014 1:20 am

This script will only work with a PPPoE connection. If you have the energy, please make a script that works with ethernet.

Thanks
I haven't tested this as I don't run a direct WAN connection, but you could try:

1. removing lines 1,3 and 4
2. change line 6 to :

:local clientip [/ip address get [find interface="ether2-master-local"] address]

(obviously change "ether2-master-local" to appropriate interface)

3. change line 7 to:

:if ($ExternalIP!=$clientip) do={


.. see how you go.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2932
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: DuckDNS Update Script (free DynDNS alternative)

Mon Apr 21, 2014 3:43 am

How to...

On the follow sript replace MATRIX with ethernet interface or bridge (probably obtaining IP by DHCP client) you want to use as source IP for DuckDNS.

1) Obtain the ip of ethernet interface, the second instruction remove /xx if present:
:global actualIP value=[/ip address get [find where interface=MATRIX] value-name=address];
:global actualIP value=[:pick $actualIP -1 [:find $actualIP "/" -1] ];
2) Read if the previous IP is different from the actual. IT ALSO REMEMBER THE IP BETWEEN REBOOTS.
First part check for file existance, the last line set previousIP variables. The delay are inserted to do time to system to write the file.
:if ([:len [/file find where name=ipstore.txt]] < 1 ) do={
 /file print file=ipstore.txt where name=ipstore.txt;
 /delay delay-time=2;
 /file set ipstore.txt contents="0.0.0.0";
};
:global previousIP value=[/file get [find where name=ipstore.txt ] value-name=contents];
3) If previous IP are different to new, update DuckDNS, and save permanently new value on files to mantain the info througt reboot:
:if ($previousIP != $actualIP) do={
 /tool fetch mode=https keep-result=yes dst-path=duckdns-result.txt address=[:resolve www.duckdns.org] port=443 host=www.duckdns.org src-path=("/update?domains=ww.matrix.it&token=65843E27-A491-429F-84A0-30A947E20F92&ip=".$actualIP);
 /delay delay-time=5;
 :global lastChange value=[/file get [find where name=duckdns-result.txt ] value-name=contents];
 :global previousIP value=$actualIP;
 /file set ipstore.txt contents=$actualIP;
};
REMEMBER TO ADD \ BEFORE ? (on "/update?doma....") IF YOU WANT TRY IT ON TERMINAL.
DO NOT PUT \ BEFORE ? INSIDE A SCRIPT.


The logging facility is added in complete version.

This is the complete script, without the interruption to explain what's happen:
:global actualIP value=[/ip address get [find where interface=MATRIX] value-name=address];
:global actualIP value=[:pick $actualIP -1 [:find $actualIP "/" -1] ];
:if ([:len [/file find where name=ipstore.txt]] < 1 ) do={
 /file print file=ipstore.txt where name=ipstore.txt;
 /delay delay-time=2;
 /file set ipstore.txt contents="0.0.0.0";
};
:global previousIP value=[/file get [find where name=ipstore.txt ] value-name=contents];
:if ($previousIP != $actualIP) do={
 :log info message=("Try to Update DuckDNS with actual IP ".$actualIP." -  Previous IP are ".$previousIP);
 /tool fetch mode=https keep-result=yes dst-path=duckdns-result.txt address=[:resolve www.duckdns.org] port=443 host=www.duckdns.org src-path=("/update?domains=ww.matrix.it&token=65843E27-A491-429F-84A0-30A947E20F92&ip=".$actualIP);
 /delay delay-time=5;
 :global lastChange value=[/file get [find where name=duckdns-result.txt ] value-name=contents];
 :global previousIP value=$actualIP;
 /file set ipstore.txt contents=$actualIP;
 :if ($lastChange = "OK") do={:log warning message=("DuckDNS update successfull with IP ".$actualIP);};
 :if ($lastChange = "KO") do={:log error message=("Fail to update DuckDNS with new IP ".$actualIP);};
};



Remember to add Karma if you find this info useful...
Thanks.
.
Last edited by rextended on Tue Apr 22, 2014 12:05 pm, edited 1 time in total.
I'm Italian, not English. Sorry for my imperfect grammar.
 
User avatar
THG
Member
Member
Posts: 472
Joined: Thu Oct 15, 2009 1:05 am

Re: DuckDNS Update Script (free DynDNS alternative)

Tue Apr 22, 2014 3:03 am

Thanks to both of you, I will test this when I have time.
 
User avatar
THG
Member
Member
Posts: 472
Joined: Thu Oct 15, 2009 1:05 am

Re: DuckDNS Update Script (free DynDNS alternative)

Mon Dec 29, 2014 2:29 am

The logging facility is added in complete version.

This is the complete script, without the interruption to explain what's happen:
Thanks, the script works very well.

Who is online

Users browsing this forum: No registered users and 13 guests