La Vita è Bear

Go dynamic DNS client for Porkbun

With the sale of Google Domains, I need to find a new home for my domains.

My main requirements for a domain registrar are:

  1. Reasonable price (not necessarily need to be the cheapest ever)
  2. Support u2f only 2fv (e.g. I’m not forced to add sms as backup 2fv)
  3. Provide free whois privacy and email forwarding
  4. Good support for dynamic DNS (I still have a home server to run)

In the end my search is narrowed to 2 candidates, Namecheap and Porkbun. Namecheap has slightly better dynamic DNS support, as ddclient supports it directly (the latest ddclient also supports Porkbun, but the version packaged by Debian does not), but Porkbun is cheaper and the price is more transparent.

At first I was most settled at Namecheap, but with some further digging I found that Porkbun’s API is quite reasonable, so I ended up writing my own Dynamic DNS client in Go and transferred all my domains to Porkbun.

The code is on Github. To install it, simply run:

go install -trimpath go.yhsif.com/ddporkbun@latest

Notes:

  1. -trimpath is optional but it generates cleaner logs
  2. It requires go1.21rc3 and above

After that, you can run it manually to update dyndns.mydomain.com to your current external IP with:

ddporkbun --apikey="pk1_..." --secretapikey="sk1_..." --domain="mydomain.com" --subdomain="dyndns"

You can also put it into cron jobs (for example, /etc/cron.hourly). When you do so it’s strongly recommended to add --log-level=ERROR arg so it only logs when something wrong happens, as you likely don’t want to receive mails for successful runs every hour:

#!/bin/sh

/path/to/ddporkbun --apikey="pk1_..." --secretapikey="sk1_..." --domain="mydomain.com" --subdomain="dyndns" --log-level=ERROR
#English #go #tech #porkbun