An octoDNS provider that targets Hetzner DNS.
pip install octodns-hetzner
Pin specific versions or SHAs in your project to control upgrades. Refer to
PyPI for current releases. Minimum requirements align with setup.py, e.g.:
octodns>=1.5.0
octodns-hetzner>=1.0.0
providers:
hetzner:
class: octodns_hetzner.HetznerProvider
# Your Hetzner API token (required)
token: env/HETZNER_TOKEN
# Choose backend during transition to Cloud Zones API
# - dnsapi (default): uses Hetzner DNS Console API (current behavior)
# - hcloud: uses Hetzner Cloud API (Zones). Requires a Cloud API token
backend: dnsapidnsapi(default): uses Hetzner DNS Console API with DNS tokens. Backward compatible with existing setups.hcloud: uses Hetzner Cloud API Zones via the officialhcloudclient. Requires a Hetzner Cloud API token. Thehcloudclient library is installed as a dependency of this package.
Both backends will co-exist until at least May 2026. The default remains dnsapi; opt into hcloud when ready.
Note: The hcloud backend is new and may evolve. Apply (writes) are implemented via RRSet semantics in the provider, with a thin adapter using the official hcloud client. When zone/rrset TTLs are unavailable from the API, a conservative fallback of 3600 seconds is used.
You can configure multiple provider instances with different backends to migrate zones gradually:
providers:
hetzner-dns:
class: octodns_hetzner.HetznerProvider
token: env/HETZNER_DNS_TOKEN
backend: dnsapi
hetzner-cloud:
class: octodns_hetzner.HetznerProvider
token: env/HETZNER_CLOUD_TOKEN
backend: hcloud
zones:
# Legacy zone still using DNS Console API
legacy.example.com.:
sources:
- hetzner-dns
targets:
- hetzner-dns
# Zone migrated to Cloud Zones API
migrated.example.com.:
sources:
- hetzner-cloud
targets:
- hetzner-cloudMigration Steps:
- Prepare: Ensure you have a Hetzner Cloud API token available for
hcloud. - Configure: Add a second provider instance with
backend: hcloudand the Cloud API token - Test: Run
octodns-sync --dry-runto validate the new provider can read zones - Migrate: Update zone configuration to use the new provider
- Verify: Confirm DNS records are identical using
octodns-compare - Repeat: Migrate remaining zones one at a time
Token Requirements:
dnsapibackend: Requires DNS Console API token (from DNS Console)hcloudbackend: Requires Hetzner Cloud API token (from Cloud Console)- Tokens are not interchangeable between backends
HetznerProvider supports A, AAAA, CAA, CNAME, DS, MX, NS, PTR, SRV, TLSA, and TXT
Long TXT records (such as DKIM keys exceeding 255 characters) are automatically
chunked into RFC-compliant format when using the hcloud backend. For DKIM keys,
configure them as a single TXT value in your zone file:
dkim._domainkey:
type: TXT
value: "v=DKIM1\\;k=rsa\\;p=MIIBIjANBgkqh...very-long-key..."The provider will automatically split values exceeding 255 characters into
properly quoted chunks (e.g., "chunk1" "chunk2"). Do not manually split long
values into multiple values: entries unless you specifically need multiple
distinct TXT records (such as for site verification).
HetznerProvider supports full root NS record management.
HetznerProvider does not support dynamic records.
See the /script/ directory for some tools to help with the development process. They generally follow the Script to rule them all pattern. Most useful is ./script/bootstrap which will create a venv and install both the runtime and development related requirements. It will also hook up a pre-commit hook that covers most of what's run by CI.