Skip to content

filiparag/hetzner_ddns

Repository files navigation

Hetzner Dynamic DNS Daemon

A simple daemon to continuously update Hetzner DNS A and AAAA records for your server with a dynamic IP address.

It features support for multiple subdomain records with painless configuration and administration.

Installation

Prebuilt packages

Officially supported operating systems:

Packages for the latest stable version can be found here.

Feel free to contribute to first-party support for other operating systems.

Manual Installation

Dependencies: awk, curl, jq.

# Download
git clone https://github.com/filiparag/hetzner_ddns.git
cd hetzner_ddns

# Install
sudo make install

# systemd service
sudo make systemd

# FreeBSD service
sudo make freebsd-rc

# NetBSD service
sudo make netbsd-rc

# OpenRC service
sudo make openrc

Configuration

Configuration file is located at /usr/local/etc/hetzner_ddns.conf

# Seconds between updates / TTL value
interval='60'

# Hetzner DNS API key
key='18fe3b02339b23ef2418f9feda1b69ef'

# Top level domain name
domain='example.com'

# Space separated host subdomains (@ for domain itself)
records='homelab media vpn'

To obtain an API key, go to Hetzner DNS Console.

Configuration for prebuilt packages

Default configuration location differs in prebuilt packages:

  • Linux distributions: /etc/hetzner_ddns.conf
  • FreeBSD: /usr/local/etc/hetzner_ddns.conf
  • NetBSD: /usr/pkg/etc/hetzner_ddns.conf

Manage records for multiple domains

Currently, this utility supports management of one domain per daemon. If you have multiple domains, use CNAME records to point them to one the daemon will manage, as shown in the following example:

# Managed domain (master.tld)
@		IN	A	    1.2.3.4
@		IN	AAAA	1:2:3:4::

# Other domain
service		IN	CNAME	master.tld.

Multiple daemon instances for systemd

If your operating system relies on systemd, you can easily run multiple daemons as shown below:

# Create configuration file for foobar.tld domain
sudo cp -p /usr/local/etc/hetzner_ddns.conf.sample /usr/local/etc/hetzner_ddns.foobar.conf

# Modify created file to reflect your preferences

# Enable and start foobar.tld's daemon
sudo systemctl enable hetzner_ddns@foobar

Usage

Run on startup

# systemd
sudo systemctl enable hetzner_ddns

# FreeBSD and NetBSD
sudo service hetzner_ddns enable

# OpenRC
sudo rc-update add hetzner_ddns

Start/Stop

# systemd
sudo systemctl start/stop hetzner_ddns

# FreeBSD, NetBSD and OpenRC
sudo service hetzner_ddns start/stop

Log file is located at /var/log/hetzner_ddns.log