This post will address how to properly configure the dynamic DNS client ddclient when being used with NameCheap.
I often face issues dealing with dynamically assigned IP addresses. A dynamic IP address is one that can change periodically. How often depends on a lot on the particular circumstances, my home IP changes only two or three times a year, but one of my clients IP addresses seems to be changing almost daily. If you find yourself in a situation similar to my client where you need to connect to a network over the internet, but that network’s external IP address is constantly changing, a dynamic DNS (DDNS) service is a good solution.
In my case I have a computer at the clients location running Xubuntu Linux (Ubuntu with the Xfce interface) and I use NameCheap as my domain registrar. If you use NameCheap’s DNS servers, you can also use their free dynamic DNS service. Linux has a popular and simple DDNS utility called ddclient. This software has a setup wizard that helps to configure it to several of the popular services, but NameCheap was not one of them. It took me much longer than it should stumbling around online and talking to NameCheap support to figure out the correct settings. I’m hoping to save some others that time by documenting what worked in my case.
I’m going to assume that you have a computer that is already setup on the subject network and is able to connect to the internet. You should have a domain registered with NameCheap and NameCheap should be providing the DNS services for that domain. You will also need root access to the system (the ability to run sudo commands).
The first step is to configure NameCheap for dynamic DNS and get the password you’ll need (this is a different password than your login). In my case ,I am setting up ddns on a sub-domain xyz.mysite.com. Log into your NameCheap account, go to the dashboard and then select the domain you’re going to configure.
- On the left side of the screen under “Miscellaneous” select the “Dynamic DNS” option.
- Select the “Enable Dynamic DNS for this domain…” and click the “Save Changes” button
- Write down the long password that it provides.
- On the left side of the screen under “Host Management” select the “All Host Records” link.
- Under “SUB-DOMAIN SETTINGS” enter your sub-domain (only the part in front of the domain, so in my case of xyz.mysite.com, I only type in xyz)
- In the box to the right, type in an easily identifiable IP address like 22.214.171.124 (You can put in any IP address you like, but I put in one that is easy to identify so I can tell when it updates and confirm that everything is working)
- In the next box to the right, select “A (Address)” from the drop down menu.
- Click “Save Changes” at the bottom of the page
Congratulations, the first step is complete!
Install and configure ddclient:
The next step is to get ddclient installed and working on the computer. If you already have ddclient installed, you can just skip to the first few steps and jump to the configuration.
First we need to install ddclient:
#udo apt-get install ddclient
During the installation, a configuration wiziard will appear. NameCheap is not one of the options provided, so select “other” and then just press enter leaving all the spaces blank. We will modify the configuration file next.
Next we will edit the configuration file to get all the settings for NameCheap correct. You can use whatever editor you want, I use Vim (vi). If you use Vim and are not familiar with it, I recommend checking out this page that I often refer to. Open the configuration file:
sudo vi /etc/ddclient.conf
Since I skipped entering anything in the setup wizard, my config file is pretty spare. It looks like this:
# Configuration file for ddclient generated by debconf
After updating the configuration file, mine looks basically like this. Make sure to read through the explanation below to understand what everything does. There are a few catches like the server address and password that took me a while to figure out.
# Configuration file for ddclient
use=web, web=checkip.dyndns.com/, web-skip=’IP Address’
So what have we done here:
- The lines starting with a “#” are comments, I chose to change them, but you are free to leave what’s there, or add any. They do not impact anything
- To run the program as a daemon, we add “daemon=xxx” where xxx is the time in second to update. I chose 300 which is once every 5 minutes.
- The next line tells ddclient to use SSL, meaning that the communications are secure (that’s always a good thing, right?)
- The next line tells ddclient to ask an outside website what your external IP address is. A computer on the local network is hidden behind your firewall/NAT and does not know what the outside address is. This address is what will be sent to NameCheap.
- The next line uses the NameCheap protocol. If this is in there, i’m not sure why it’s not an option on the configuration wizard!
- This next line is what took me a while to figure out. Enter this line just as it is here, this is the address you want to use. I was changing this to mysite.com and it was not working!
- The next line is for your login. NameCheap says it does not use this, and I did not test it thoroughly, it works like this and I don’t see any issues with leaving it here.
- The next line is the password you obtained from NameCheap above. Do not put any single or double quotes around it like the configuration wizard does, it wont work! (I spent a good two hours until I figured that one out.)
- The last line should be the sub-domain you wish to update the IP of. Just put the part in front of the decimal before the domain. In my case it’s xyz for the sub-domain xyz.mysite.com. If you want to update the root domain (mysite.com), just use the @ symbol.
When you have saved that file, run ddclient with the following command. This will output everything it’s doing and is a great tool for debugging:
sudo ddclient -daemon=0 -debug -verbose -noquiet
This is only a basic introduction documenting what I have done. It should get you up and running with ddclient and NameCheap quickly. This is a powerfull little program and there is a lot more that can be done with it. I suggest checking out the following links for more details: