How to Use ddclient to Update Dynamic DNS Settings on Google Domains
Update on June 2024: Since Google Domains is now deprecated, I recommend using CloudFlare DDNS. It is free, even if your domain is not registered on CloudFlare. I use this Docker image to update the A record every minute. CapRover app repository has it in the app repository, it is straightforward to configure with environment variables, just following the instructions of the Docker image.
If you are running a web server, VPN, or any other device at home which you want to access over the internet using a domain or subdomain name, you either need a static IP address (which many ISPs do not provide or charge extra for) or you will need a Dynamic DNS setup that changes your DNS records every time your IP address changes. Google Domains offers this service for free and without any strings attached like NoIP’s confirmation requirement every 30 days.
1. Identify Your Network Interface
We will need to know the name of the network interface that ddclient will use, so run the following command:
sudo lshw
Look for the following lines that begin with *-network
in the output and note the logical name of the network interface you are using. That would be eth0
for the case below as this device was connected via ethernet.
[...]
*-network:0 DISABLED
description: Wireless interface
physical id: 1
logical name: wlan0
[...]
*-network:1
description: Ethernet interface
physical id: 2
logical name: eth0
[...]
2. Obtain DNS Credentials from Google Domains
Login to Google Domains, select the domain you want to point to this server and open DNS records by clicking DNS. Click Show Advanced Settings at the bottom of the page, then Manage dynamic DNS and create a new record as you would do with other records. Finally click View dynamic DNS credentials then View and note the credentials.
3. Install and Cofigure ddclient
Install it (you can skip the questions during installation by hitting Enter):
apt install ddclient
Edit the configuration with:
sudo nano /etc/ddclient.conf
It should look similar to this, but with your DNS credentials we obtained earlier and the domain would be depending on what you set up on the dynamic DNS section.
protocol=dyndns2
use=web
server=domains.google.com
ssl=yes
login=GOOGLEDNSUSERNAME
password=GOOGLEDNSPASSWORD
yourdomain.com
If you want to update multiple DNS records, just repeat these steps and append the configuration in the ddclient.conf
file.
4. Testing
The following runs the update sequence:
sudo ddclient -daemon=0 -debug -verbose -noquiet
If you see a line towards the end of the output showing Google responded with good and your IP address, it is working.
RECEIVE: good YOURIPADDRESS
Test double-check, you can point your DNS to a fake IP address by going to the following URL with your details:
https://username:password@domains.google.com/nic/update?hostname=subdomain.yourdomain.com&myip=1.2.3.4
If you run the ddclient daemon again, it will compare its IP address with the address it cached (not with the one we changed using the GET request above); therefore will think its IP hasn’t changed. So you need to delete its cache and then run the update sequence as below.
sudo rm -f /var/cache/ddclient/ddclient.cache
Further Reference
See Google DNS help article for other responses.