A little background information:
- I have a few domains registered via Google Domains
- These domains have their DNS hosted with Google Domains
What I wanted to do was have my Raspberry Pi dynamically update a DNS record, so that no matter where it was, the record was updated with the Raspberry Pi’s public IP address. In that fashion, I could always hit raspberrypi.mydomain.com, without having to worry if the IP Address had changed or not.
Fortunately, Google has recently added dyndns2 protocol support to Google Domains. So all we have to do is configure a compatible dynamic DNS updater.
Create a Dynamic DNS Record
- Log into your account at https://domains.google.com
- Click on “DNS” next to the domain you wish to configure a record for
- Scroll down to “Synthetic Records”
- Choose “Dynamic DNS” from the drop down menu
- Type in a subdomain name for your record
- Click Add
After you’ve added a record, if you click on the record and then “View Credentials”, you will have the information you need to setup DDClient to point to and update this record.
sudo apt-get install ddclient
Right after install, a Wizard will pop up. You can enter anything you want on this, as we are primarily concerned with the configuration file.
Once installation is complete, we want to edit the /etc/ddclient.conf file to put in true values instead of whatever was entered with the wizard. Here is my working ddclient.conf file, sanitized of course.
protocol=dyndns2 #use=if, if=wlan0 use=web, web=checkip.dyndns.org ssl=yes server=domains.google.com login=googleloginhere password='googlepasswordhere' subdomain.domain.tld daemon=300
- Reboot the Pi or restart the DDClient.
A couple of important points:
- If you do not comment out “use=if, if=wlan0” and add the next line referencing checkip.dyndns.org, then DDClient will update your public DNS record with its private IP Address. The checkip.dyndns.org line will make sure that your DNS record has the devices public IP Address listed.
- The daemon= line tells the ddclient how often to update the DNS record.
Hope this helps.