Linux Make ddclient Work with Multiple Namecheap Domains

• Updated February 7, 2019


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 example.com and foobar.com 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:

  • example.com
  • www.example.com
  • mail.example.com
  • smtp.foobar.com
protocol=namecheap,                      \
server=dynamicdns.park-your-domain.com,  \
login=example.com                        \
password=faefjawpefoij30498320493r23     \
@, www, mail

protocol=namecheap,                      \
server=dynamicdns.park-your-domain.com,  \
login=foobar.com                         \
password=faefjawpefoij30498320493r23     \
@, www, mail, smtp

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

  • foobar.com
  • www.foobar.com
  • mail.foobar.com

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.

Thanks to reader @madsmide for letting me know that as of ddclient 3.8.3 the following steps are not needed.

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,                      \
server=dynamicdns.park-your-domain.com,  \
login=example.com                        \
password=yourpasswordhere                \
@.example.com, www.example.com, mail.example.com

protocol=namecheap,                      \
server=dynamicdns.park-your-domain.com,  \
login=foobar.com                         \
password=yourpasswordhere                \
@.foobar.com, www.foobar.com, mail.foobar.com, smtp.foobar.com

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.

References

If you found this post useful and would like to help support this site - and get something for yourself - sign up for any of the services listed below through the provided links.

The following links are part of affiliate programs, and I will receive a referral payment from any of the services you sign-up for.

  • Get Faster Shipping: About to order some stuff on Amazon but want to get more value out of the money you would normally pay for shipping? Sign-up for a free, 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.
  • Start Investing Now: Looking to start investing some of your saved income? Get started by opening an account with Webull, where upon sign-up and opening a brokerage account with an initial deposit of $100 or more you will receive free stock(s). The promotions are always changing, so be sure to click the link to see the latest.

Thanks for reading and take care.