Guide: Add custom DDNS service to Synology

Questions and mods regarding system management may go here
Forum rules
Please note the disclaimer before modifying your Synology Product.
johanneso
Trainee
Trainee
Posts: 11
Joined: Wed Jun 12, 2013 8:02 pm

Guide: Add custom DDNS service to Synology

Postby johanneso » Thu Jun 13, 2013 2:43 pm

Hi,
I'm a Synology noob and wanted to add a custom DDNS service to my DiskStation. I've found tidbits here and there but thought we could do with a coalesced guide... So here's my try.

1. Open the DSM Control Panel, Terminal. Enable SSH.
2. Open Terminal on your Mac (or install PuTTy on your Windows machine). Find the IP adress of your Synology and log into it as root (not admin). In terminal the syntax would be "ssh root@192.168.1.xxx" and press enter. Now input your admin account password and you're logged in as root. Don't do anything else than what we do next!
3. Next we need to make the DynDNS services database editable. Type "chmod +w /etc.defaults/ddns_provider.conf" and press enter.
4. Now we'll add a new DDNS service. Type "vi /etc.defaults/ddns_provider.conf" and press enter. You're now using a text editor to look inside the DDNS services database.
5. Press "i" to enter edit mode. Using the down key, scroll down until the rows starting with hash tags end. Here's the list. Now lets input our own service, in my case swedish provider Loopia. To make the structure as nice as the rest of the list, use the Tab key to move the second line a bit further in. Type:"
[Loopia.se]
modulepath=DynDNS
queryurl=dns.loopia.se/XDynDNSServer/XDynDNS.php?hostname=__HOSTNAME__&myip=__MYIP__
"
6. Press the escape button twice to get out of edit mode. Now type ":wq" to save and quit the text editor. Type "exit" to close your SSH connection to the Synology.
7. Now, go back to the DSM Web interface Control Panel and click DDNS. Click Add and now you can select Loopia.se in the Service Provider list. Just add the Host, username and password to your other DDNS provider and you should be golden.

Hope this works for other people than me. It was a hassle to piece together all the info so I thought it would be nice to have it all in one place.
eflex
I'm New!
I'm New!
Posts: 4
Joined: Sat May 04, 2013 5:09 pm

Re: Guide: Add custom DDNS service to Synology

Postby eflex » Thu Oct 10, 2013 3:05 pm

I'm new to this too, is Synology able to include this without having to delve into editing? I have a domain through Enom, can't figure out how to add it, even the free ddns service provider synology pointed me to, (No-IP) has been dropped off the list of 13. I'd love to just consolidate everything.
johanneso
Trainee
Trainee
Posts: 11
Joined: Wed Jun 12, 2013 8:02 pm

Re: Guide: Add custom DDNS service to Synology

Postby johanneso » Sat Nov 02, 2013 3:51 pm

If you want to use your own domain, your domain name supplier and their DNS servers need to support dynamic DNS somehow. Ask them if they have an interface/API for external access like in my example above! Then you can use the instructions here and try it out.
purepense
I'm New!
I'm New!
Posts: 1
Joined: Thu Nov 14, 2013 7:43 am

Re: Guide: Add custom DDNS service to Synology

Postby purepense » Thu Nov 14, 2013 8:18 am

I use your instructions but using chmod +w /etc.defaults/ddns_provider.conf I receive this error message
chmod +w /etc.defaults/ddns_provider.conf
chmod: /etc.defaults/ddns_provider.conf: Operation not permitted

Any idea why I receive that message?
mgutt
Beginner
Beginner
Posts: 21
Joined: Thu Nov 15, 2012 10:54 am

Re: Guide: Add custom DDNS service to Synology

Postby mgutt » Tue Feb 18, 2014 11:46 am

For those who are interested in using their own API. You need to answer with "nochg" or "good" to avoid error messages in the synology protocol list. Here is the complete list of possible commands:
# Output:
# When you write your own module, you can use the following words to tell user what happen by print it.
# You can use your own message, but there is no multiple-language support.
#
# good - Update successfully.
# nochg - Update successfully but the IP address have not changed.
# nohost - The hostname specified does not exist in this user account.
# abuse - The hostname specified is blocked for update abuse.
# notfqdn - The hostname specified is not a fully-qualified domain name.
# badauth - Authenticate failed.
# 911 - There is a problem or scheduled maintenance on provider side
# badagent - The user agent sent bad request(like HTTP method/parameters is not permitted)
# badresolv - Failed to connect to because failed to resolve provider address.
# badconn - Failed to connect to provider because connection timeout.
#


e.g. it is important to include the word "good" or "nochg":

Code: Select all

exit("The ip has not changed (nochg)!");


purepense wrote:Any idea why I receive that message?


Did you use the user "root" to login to Putty or did you use an usual admin account (wrong)?
JeanDavid
I'm New!
I'm New!
Posts: 1
Joined: Sun Jun 29, 2014 2:13 pm

Re: Guide: Add custom DDNS service to Synology

Postby JeanDavid » Sun Jun 29, 2014 2:36 pm

Hello, and thanks to everyone
I actually used the information here and managed to add a new DDNS service, I felt like giving some feedback on the use of bash scripts.
So I followed the instructions using Terminal
1) ssh root@192.168.1.x , enter, then password, enter

2) to edit the ddns_provider.conf document, I actually copied it in the web volume :
cp /etc.defaults/ddns_provider.conf /volume1/web/

4) and then edited it there with my favorite text editor, smultron, in the web folder. It is much easier than the vi command.
I wanted to add a yDNS service, so I actually used the possibility of self made script
I added to the file these 2 lines

[yDNS]
modulepath=/sbin/myscript.sh

and then saved and copied it back to where it belongs , in the terminal :
cp /volume1/web/ddns_provider.conf /etc.defaults/

5) then you have to add the script, I found the one for yDNS there :
https://github.com/commx/ydns/blob/master/updater.sh

6) edited the first line, bash is not available on synology :
!/bin/ash

edit the user, password and host , using the API values available in your account online. ( free service )
added a printf "good" in the loop that gets the OK reply, to get the answer in the pannel when the update has succeeded.

7) then copied this script file to the /sbin/ folder on the NAS
so if you put the script in the web folder, the command would be :
cp /volume1/web/myscript.sh /sbin/

Restart the NAS to get it working. Hope this helps.
cyberderf
Beginner
Beginner
Posts: 22
Joined: Fri Sep 19, 2014 11:21 pm

Re: Guide: Add custom DDNS service to Synology

Postby cyberderf » Fri Sep 19, 2014 11:33 pm

Hi Jean David and thanks for your guide. However, it's not really working for me. I think I did't get what you meant for the first line.

The first lines are :

if ! hash curl 2>/dev/null; then
echo "ERROR: cURL is missing."
exit 1
fi

What should I write ?
Starting
I'm New!
I'm New!
Posts: 1
Joined: Sat Oct 18, 2014 1:18 pm

Re: Guide: Add custom DDNS service to Synology

Postby Starting » Sat Oct 18, 2014 1:22 pm

Got it to work. Copy and paste this in.

[Namesheap.com]
modulepath=DynDNS
queryurl=dynamicdns.park-your-domain.com/update?host=__HOSTNAME__&domain=__DOMAINID__&password=__PASSWORD__&ip=__MYIP__
hakbr
I'm New!
I'm New!
Posts: 2
Joined: Sun Nov 30, 2014 1:46 pm

Re: Guide: Add custom DDNS service to Synology

Postby hakbr » Sun Nov 30, 2014 7:00 pm

I have used your guide for quite some time now, but since I upgraded DSM to version 5.1-5004 Update 2 it don't seem to work anymore.

Is there anyone that has encountered the same problem?

I would really appreciate some help with this... :-)
/Håkan

johanneso wrote:Hi,
I'm a Synology noob and wanted to add a custom DDNS service to my DiskStation. I've found tidbits here and there but thought we could do with a coalesced guide... So here's my try.

1. Open the DSM Control Panel, Terminal. Enable SSH.
2. Open Terminal on your Mac (or install PuTTy on your Windows machine). Find the IP adress of your Synology and log into it as root (not admin). In terminal the syntax would be "ssh root@192.168.1.xxx" and press enter. Now input your admin account password and you're logged in as root. Don't do anything else than what we do next!
3. Next we need to make the DynDNS services database editable. Type "chmod +w /etc.defaults/ddns_provider.conf" and press enter.
4. Now we'll add a new DDNS service. Type "vi /etc.defaults/ddns_provider.conf" and press enter. You're now using a text editor to look inside the DDNS services database.
5. Press "i" to enter edit mode. Using the down key, scroll down until the rows starting with hash tags end. Here's the list. Now lets input our own service, in my case swedish provider Loopia. To make the structure as nice as the rest of the list, use the Tab key to move the second line a bit further in. Type:"
[Loopia.se]
modulepath=DynDNS
queryurl=dns.loopia.se/XDynDNSServer/XDynDNS.php?hostname=__HOSTNAME__&myip=__MYIP__
"
6. Press the escape button twice to get out of edit mode. Now type ":wq" to save and quit the text editor. Type "exit" to close your SSH connection to the Synology.
7. Now, go back to the DSM Web interface Control Panel and click DDNS. Click Add and now you can select Loopia.se in the Service Provider list. Just add the Host, username and password to your other DDNS provider and you should be golden.

Hope this works for other people than me. It was a hassle to piece together all the info so I thought it would be nice to have it all in one place.
kjkunk
I'm New!
I'm New!
Posts: 7
Joined: Thu Jan 13, 2011 1:51 pm

Re: Guide: Add custom DDNS service to Synology

Postby kjkunk » Tue Jan 13, 2015 12:17 am

After the update the custom DDNS vanished
hakbr
I'm New!
I'm New!
Posts: 2
Joined: Sun Nov 30, 2014 1:46 pm

Re: Guide: Add custom DDNS service to Synology

Postby hakbr » Tue Jan 13, 2015 8:19 am

Hello again.

I contacted the Synology support and got this answer:

"Many thanks for your recent support request regarding the addition of Custom DDNS Providers, Please note that we do not provide support for Command Line Alterations to the underlying DSM OS

However I have tested the provided steps and can confirm that the proccess works on DSM 5.1 and Loopia is added to the DDNS List."

Maybe I did something wrong and I am going to update to the latest version soon and after that try the guide again.

However I have noticed in the past that every update of the DSM-firmware require that I add the DDNS-entry again as it seems that the DMS-update replaces the file containing DDNS-entries every time.

/Håkan
josh.lawless
Student
Student
Posts: 68
Joined: Thu Feb 10, 2011 3:40 am

Re: Guide: Add custom DDNS service to Synology

Postby josh.lawless » Tue Jan 13, 2015 11:51 pm

I found a solution to the hassle of not being able to update namecheap DNS records without installing multiple community packages -- use the Synology DDNS to update a custom synology address (e.g., myname.synology.me), then include a CNAME host record at namecheap to point to your synology address.

Maybe everyone else already knew this, but it was a big discovery for me.


Namecheap record example:

Host Address Type
@ http://www.mydomain.com URL Redirect
www myname.synology.me CNAME (Alias)

I'm told by the namecheap staff that doing it the other way (i.e., putting the CNAME record on the "@" host may cause problems with email handling)
antonybristol
I'm New!
I'm New!
Posts: 3
Joined: Fri May 27, 2011 2:41 pm

Re: Guide: Add custom DDNS service to Synology

Postby antonybristol » Tue Feb 17, 2015 3:06 pm

I have been playing around adding a custom module which supports Namecheap's native update mechanism (dynamicdns.park-your-domain.com) which plays nice with the DSM control panel. For those that are interested these are the following changes that need to be made to the DSM firmware. Note that you will need to login to your DS as root (same password as your admin account).

[1] Create a file called namecheap.php in the directory /usr/syno/bin/ddns with the following contents:

Code: Select all

#!/usr/bin/php -d open_basedir=/usr/syno/bin/ddns
<?php

if ($argc !== 5) {
    echo 'badparam';
    exit();
}

$account = (string)$argv[1];
$pwd = (string)$argv[2];
$hostname = (string)$argv[3];
$ip = (string)$argv[4];

// check the hostname contains '.'
if (strpos($hostname, '.') === false) {
    echo 'badparam';
    exit();
}

// only for IPv4 format
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
    echo "badparam";
    exit();
}

$array = explode('.', $hostname);
$domain = implode('.', array_slice($array, 1));
$hostname = implode('.', array_slice($array, 0, 1));

$url = 'https://dynamicdns.park-your-domain.com/update?host='.$hostname.'&domain='.$domain.'&password='.$pwd.'&ip='.$ip;

$req = curl_init();
curl_setopt($req, CURLOPT_URL, $url);
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($req);
curl_close($req);

/*

Success response:

<?xml version="1.0"?>
  <interface-response>
    <Command>SETDNSHOST</Command>
    <Language>eng</Language>
    <IP>%ip-address%</IP>
    <ErrCount>%error-count%</ErrCount>
    <ResponseCount>%response-count%</ResponseCount>
    <Done>true</Done>
    <debug><![CDATA[]]></debug>
</interface-response>

%ip-address% = IP address
%error-count% = 0
%response-count% = 0

Failure response:

<?xml version="1.0"?>
  <interface-response>
    <Command>SETDNSHOST</Command>
    <Language>eng</Language>
    <ErrCount>%error-count%</ErrCount>
    <errors>
      <Err1>%error-message%</Err1>
    </errors>
    <ResponseCount>%response-count%</ResponseCount>
    <responses>
      <response>
        <ResponseNumber>%response-number%</ResponseNumber>
        <ResponseString>%response-message%</ResponseString>
      </response>
    </responses>
    <Done>true</Done>
    <debug><![CDATA[]]></debug>
</interface-response>

%error-count% = 1
%error-message% = Error message
%response-count% = 1
%response-number% = Code for response message
%response-message% = Response message (similar to %error-message%)

*/

$xml = new SimpleXMLElement($res);
if ($xml->ErrCount > 0) {
    $error = $xml->errors[0]->Err1;
    if (strcmp($error, "Domain name not found") === 0) {
        echo "nohost";
    } elseif (strcmp($error, "Passwords do not match") === 0) {
        echo "badauth";
    } elseif (strcmp($error, "No Records updated. A record not Found;") === 0) {
        echo "nohost";
    } else {
        echo "911 [".$error."]";
    }
} else {
    echo "good";
}


For example:

% vi /usr/syno/bin/ddns/namecheap.php
...paste in contents from above...
% chmod 755 /usr/syno/bin/ddns/namecheap.php


[2] Add the following lines to /etc.defaults/ddns_provider.conf:

Code: Select all

[Namecheap.com]
        modulepath=/usr/syno/bin/ddns/namecheap.php
        queryurl=https://dynamicdns.park-your-domain.com/


For example:

% vi /etc.defaults/ddns_provider.conf
...paste in contents from above...


This should be sufficient for Namecheap.com to appear as a DDNS provider in the DSM control panel (you may have to revisit the External Access applet for the new provider to appear).

Note that since Namecheap do not require a user name (or email address) when updating you can put any value in for the control panel user name field.

Hope this is of use to somebody.
Hanuman
Novice
Novice
Posts: 53
Joined: Mon May 12, 2014 6:21 am

Re: Guide: Add custom DDNS service to Synology

Postby Hanuman » Mon Apr 06, 2015 10:10 am

Or you can use this DDNS provider too: http://raphael.li/resources/custom-ddns ... -provider/
DS214+
User avatar
cnyc
Versed
Versed
Posts: 234
Joined: Mon Feb 02, 2015 2:13 am

Re: Guide: Add custom DDNS service to Synology

Postby cnyc » Fri Jun 12, 2015 3:43 pm

@planskiman @anthonybristol

thank you both, I tried both and the one that works was with with nsupdate.info. It spitted out a log file... :D

@anthonybristol, yours get me an unknown error. Certainly, I would encourage both ways, your mileage may vary. I learnt something about vi. :shock:
ds1815+ >>> 5 x 6TB WD Red (shr2), 2+4gb ram (KVR16LS11/4) >>> 2 x 500GB SSD as cache >>> 4 ports link aggregation >>> hp1810-24G v2 >>> APC UPS ES 750 >>> latest DSM

Return to “System Managment Mods”

Who is online

Users browsing this forum: No registered users and 2 guests