Skip to content

Instantly share code, notes, and snippets.

@gbraad
Created February 4, 2025 07:51
Show Gist options
  • Save gbraad/e167a509a902263ed67264f346937aae to your computer and use it in GitHub Desktop.
Save gbraad/e167a509a902263ed67264f346937aae to your computer and use it in GitHub Desktop.
Update Dynamic DNS using SystemD timers (instead of cron-schedule)

Dynamic DNS update script using systemd

Here Free DNS is used as an example, but many service can be used in a similar way.

Create the following service and related timer: /etc/systemd/system/freedns-update.service

[Unit]
Description=Update service for Free DNS A record: systemd.strangled.net
Wants=freedns-update.timer

[Service]
Type=oneshot
ExecStart=curl -fsSL https://freedns.afraid.org/dynamic/update.php?dEljVlh3ME5jTnN0NFJwa2dCdDBMM2lBOjIzNzI3MDQx

[Install]
WantedBy=multi-user.target

/etc/systemd/system/freedns-update.timer

[Unit]
Description=Update timer for Free DNS A record: systemd.strangled.net
Requires=freedns-update.service

[Timer]
Unit=freedns-update.service
OnCalendar=Weekly

[Install]
WantedBy=timers.target

Check if this works:

$ systemctl daemon-reload
$ journalctl -S today -f -u freedns-update.service
$ systemctl start freedns-update.service
$ systemctl status freedns-update.service

If all OK, enable:

$ systemctl enable freedns-update.timer

For more information, check: https://opensource.com/article/20/7/systemd-timers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment