There are many dynamic DNS (DDNS) providers, but I could not find one that
supports updating records using nsupdate. This guide will show how to set up
a DDNS service on your own server as well as how to integrate it with macOS to
automatically push updates whenever the machine IP changes.
First, install Knot DNS on the server. Once installed, you’ll need to generate
a TSIG key that will be used for authenticating updates to the DDNS server. To
do so, run keymgr -t tsig.example.com. This will print a configuration that
looks like the following:
key:
- id: tsig.example.com
algorithm: hmac-sha256
secret: pk6S/jO+BV1h9ig2ofS3tsPZ1nZl/lOzkimoEhwJjMA=
The next step is to add it to knot.conf, which will most likely be in
/etc/knot/knot.conf. Add the key configuration, followed by an accompanying
ACL rule and the zone information:
acl:
- id: dns-update.example.com
key: tsig.example.com
action: update
zone:
- domain: example.com
acl: dns-update.example.com
Ensure the server is listening on all interfaces to be able to access it externally:
server:
listen: [ 0.0.0.0@53, ::@53 ]
macOS Integration
To integrate with macOS’s built-in DDNS client, you’ll need to add one more record. To do so, run:
knotc zone-begin example.com
knotc zone-set example.com _dns-update._udp 600 SRV 0 0 53 example.com.
knotc zone-commit example.com
Lastly, to enable DDNS on macOS, open Sharing in System Settings, and click Edit in the hostname section at the end. Enable Use dynamic global hostname, and fill the details as follows:
- Hostname: example.com
- User: tsig.example.com
- Password: the secret generated by
keymgr