Skip to main content

Hetzner DNS Zone Manager

Project description

Hetzner DNS Manager

A command-line tool to interact with the Hetzner DNS API, allowing you to manage DNS records.

It is designed for small to medium installations with up to 100 zones. Function scope is limited to managing records within existing zones for now.

Features

  • Import zones and records from the Hetzner DNS API
  • Check DNS records against actual DNS entries
  • Create missing and update mismatched DNS records
  • Delete DNS records
  • Stores zone data in YAML files for easy manual editing

Example Workflow

After initial import, add records to a zone YAML file with empty ID:

Adding records to a zone YAML file

Then run update to push the change to the API and update the YAML file with the new ID:

Running the update command

The same way you can update records and push those.

Installation

The script uses PEP 723 for dependency management, so it's self-contained. You'll need Python 3.10 or higher and a working installation of uv, installed via your OS's package manager or via pip.

# Clone the repository
git clone https://github.com/serpent213/hetzner-dns-manager.git
cd hetzner-dns-manager

or

# Download raw script directly
curl -LO https://github.com/serpent213/hetzner-dns-manager/raw/refs/heads/master/hdem
chmod +x hdem

Install from PyPI

Alternatively install from PyPI:

# Install using pip
pip install hetzner-dns-manager

# Or with pipx for isolated installation
pipx install hetzner-dns-manager

After installation, you'll have access to the hdem command in your terminal.

Configuration

Set your Hetzner DNS API token as an environment variable:

export HETZNER_DNS_API_TOKEN="your_api_token_here"

You may want to add this to your shell profile file (.bashrc, .zshrc, etc.) for persistence.

Usage

The database will be created in ./zones and consists of one YAML file per zone.

Import Zones and Records

Import a specific zone:

hdem import example.com

Import all zones:

hdem import --all

This will create YAML files in the ./zones directory.

Check DNS Records

Check a specific zone against actual DNS entries using one of the domain's authoritative servers:

hdem check example.com

Check all zones:

hdem check --all

SOA records will be ignored as they are updated automatically by Hetzner.

Update DNS Records

Check and update mismatched records for a specific zone:

hdem update example.com

Check and update mismatched records for all zones:

hdem update --all

To create new records, add to them to your zone YAML with empty ID field, which will be filled in after creation.

Delete a DNS Record

Delete a specific record by name:

hdem delete example.com www

If there is more than one candidate, hdem will ask you which records to delete.

Data Structure

The YAML files in the ./zones directory follow this structure:

id: ZoneID
name: example.com
records:
  - id: RecordID1
    type: A
    name: www
    value: 192.0.2.1
  - id: RecordID2
    type: MX
    name: '@'
    value: '10 mail.example.com.'

Related Projects

Some other tools dealing with the Hetzner DNS API (that are not dynamic DNS updaters):

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hetzner_dns_manager-0.2.0.tar.gz (91.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hetzner_dns_manager-0.2.0-py3-none-any.whl (92.4 kB view details)

Uploaded Python 3

File details

Details for the file hetzner_dns_manager-0.2.0.tar.gz.

File metadata

  • Download URL: hetzner_dns_manager-0.2.0.tar.gz
  • Upload date:
  • Size: 91.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for hetzner_dns_manager-0.2.0.tar.gz
Algorithm Hash digest
SHA256 16d6de93f12f9bd30ea643853c3db579b860408a4aebc8d467e0690241392e87
MD5 0ebeb665fa3d06521d2223c8776feff8
BLAKE2b-256 c35c9f4fe1292fd9c37fdb6a212f995dc0fef9100357676e116e4c13674a7282

See more details on using hashes here.

File details

Details for the file hetzner_dns_manager-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hetzner_dns_manager-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 187b088b909e560bfc65dd6a1aeffc9e96154b9388c75c3f7c0e858d4608bf60
MD5 fbd48006812ada32d7322423f4a7f88f
BLAKE2b-256 3168a524c24a333a96b303b468957fb5f227b64b1a27cf18edc1d39d02d38e43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page