Mastodon

Configuring ddclient with Google Domains on macOS

Dynamic DNS gives you all of the advantages of a domain name without the hassle of a static IP address. Its principle is simple; a client on the host detects changes to your external IP address and updates the associated DNS record. One popular client available on macOS is ddclient. Here’s how to set it up with Google Domains.

Installing ddclient

Homebrew is the easiest way to install ddclient, and has the added feature of providing updates. If you haven’t already, installing Homebrew is as simple entering a single line into Terminal:

$
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install ddclient:

$
brew install ddclient

Next we need to add a synthetic record in Google Domains. Find the domain you wish to use and select “Manage.” Go to “DNS” in the navigation stack on the left, and scroll down to “Synthetic Records.” In the dropdown menu on the left, select “Dynamic DNS,” then enter the desired subdomain name, and add the record. Expand the newly-added record and select “View credentials” to get your username and password.

The username and password lives in a configuration file, ddclient.conf, located in /usr/local/etc/ddclient. A sample version of the file can be found in /usr/local/opt/ddclient/share/doc/ddclient. For Google Domains, it’s pretty simple. Here’s an example of mine:

ssl=yes
protocol=googledomains
use=web, web=checkip.dyndns.org/, web-skip='IP Address'
login=<generated_login>
password=<generated_password>
home.paysonwallach.com

The above configuration queries checkip.dyndns.org for your external IPv4 address. We should limit our daemon to query at most every 10 minutes (600 seconds) so our IP address doesn’t get blocked. Note that we don’t specify a time interval here. Although we could easily make our own launch daemon, Homebrew has already done the work for us. All we need to do is set our desired interval for the StartInterval key in /Library/LaunchDaemons/homebrew.mxcl.ddclient.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.ddclient</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/ddclient/sbin/ddclient</string>
<string>-file</string>
<string>/usr/local/etc/ddclient/ddclient.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>600</integer>
<key>WatchPaths</key>
<array>
<string>/usr/local/etc/ddclient</string>
</array>
<key>WorkingDirectory</key>
<string>/usr/local/etc/ddclient</string>
</dict>
</plist>

To start the launch daemon:

$
sudo brew services start ddclient

And there you have it! Assuming you’ve properly configured port-forwarding, you can now access your Mac from anywhere with your own domain name.