Linux Make ddclient Work with Multiple Namecheap Domains

Wednesday, August 22, 2012

Version 3.8.1 of ddclient and older will not be able to update multiple domain names with each domain name containing one to many hostnames.

For example, if you are trying to update domain names and along with their particular hostnames (@, www, or mail), ddclient will only update the first hostname it encounters for a domain name.

If your /etc/ddclient/ddclient.conf file looks like the configuration below, during each update only the following hostnames will be updated:

protocol=namecheap,                      \,  \                        \
password=faefjawpefoij30498320493r23     \
@, www, mail

protocol=namecheap,                      \,  \                         \
password=faefjawpefoij30498320493r23     \
@, www, mail, smtp

The following hostnames will not be updated because they were already checked for the first domain name:


The remainder of this post provides a patch to fix this undesired behavior.

This patch has only been tested on RHEL 6 with version 3.8.1 of ddclient. Your experience may vary with different Linux distributions and versions of ddclient. Additionally, this patch may be applied to future ddclient releases negating the need for the following steps.

Patch ddclient

Log in to the Linux server currently running ddclient.

Stop the ddclient service:

service ddclient stop

Copy the existing ddclient binary to another folder:

mkdir /root/ddclient-patch

cp /usr/sbin/ddclient /root/ddclient-patch/

Change to the patch directory:

cd /root/ddclient-patch/

Save the following patch to a text file named ddclient.patch:

--- ddclient    2012-08-22 18:49:15.643067531 -0500
+++ ddclient    2012-08-22 20:32:23.671069165 -0500
@@ -3375,8 +3375,11 @@

         my $url;
         $url   = "http://$config{$h}{'server'}/update";
-        $url  .= "?host=$h";
-        $url  .= "&domain=$config{$h}{'login'}";
+        my $domain = $config{$h}{'login'};
+        my $host = $h;
+        $host  =~ s/(.*)\.$domain(.*)/$1$2/;
+        $url  .= "?host=$host";
+        $url  .= "&domain=$domain";
         $url  .= "&password=$config{$h}{'password'}";
         $url  .= "&ip=";
         $url  .= $ip if $ip;

Apply the patch:

patch -b -p0 -i ddclient.patch

# Successful output
patching file ddclient

Copy the newly patched ddclient to /usr/sbin:

cp /root/ddclient-patch/ddclient /usr/sbin/

Modify /etc/ddclient/ddclient.conf

Modify the /etc/ddclient/ddclient.conf file and add the domain name to each hostname:

protocol=namecheap,                      \,  \                        \
password=yourpasswordhere                \,,

protocol=namecheap,                      \,  \                         \
password=yourpasswordhere                \,,,

Start the ddclient Service Again

Remove the ddclient cache file:

rm /var/cache/ddclient/ddclient.cache

Start the service:

service ddclient start

Monitor /var/log/messages to verify everything is working. The logs should clearly show each hostname being updated even if that hostname has already been updated on a different domain name.


ddclient namecheap multiple updates

Making DDClient work with multiple domains on namecheap

comments powered by Disqus