Best way to set up dynamic DNS?

Posted on

I have a RHEL 9 DNS server in the cloud for my domain. I've got dynamic DNS set up. I have a RHEL 9 firewall machine at my home office, and I can run a shell script on that firewall to update DNS on the server in the cloud. It works great from the command line.

My question is, what's the "right" way to have the firewall machine update DNS when its IP address changes? Is the right way to create a unit file so that, when the IP address changes on the firewall machine, it triggers the unit file to update the DNS in the cloud? Would it be an addition to, maybe NetworkManager.service like:

[Unit]
Before=ddns.service
Wants=ddns.service

Or should it be triggered by another unit file? I guess my question is more "which service unit file is the one which is used when my DHCP issued address changes?"

Or am I going at this the wrong way? I can always do a cron job to update DNS every few minutes or something, but that seems silly. What's the "right" way to update dynamic DNS when my IP address changes?

Responses