Synchronize your DNS to multiple providers from a simple DSL
Find a file
Jakob Ackermann 1e67585e8f
HETZNER_V2: Add provider for Hetzner DNS API (#3837)
Closes https://github.com/StackExchange/dnscontrol/issues/3787

This PR is adding a `HETZNER_V2` provider for the "new" Hetzner DNS API.

Testing:
- The integration tests are passing.
- Manual testing:
  - `preview` (see diff for existing zone)
- `preview --populate-on-preview` (see full diff for newly created zone)
  - `push` (see full diff; no diff after push)
- `push` (see full diff; no diff after push to newly created zone --
i.e. single pass and done)

```js
var REG_NONE = NewRegistrar('none')
var DSP = NewDnsProvider('HETZNER_V2')

D('testing-2025-11-14-7.dev', REG_NONE, DnsProvider(DSP),
    A('@', '127.0.0.1')
)
```

<details>

```
# push for newly created zone
CONCURRENTLY checking for 1 zone(s)
SERIALLY checking for 0 zone(s)
Waiting for concurrent checking(s) to complete...DONE
******************** Domain: testing-2025-11-14-7.dev
1 correction (HETZNER_V2)
#1: Ensuring zone "testing-2025-11-14-7.dev" exists in "HETZNER_V2"
SUCCESS!
CONCURRENTLY gathering records of 1 zone(s)
SERIALLY gathering records of 0 zone(s)
Waiting for concurrent gathering(s) to complete...DONE
******************** Domain: testing-2025-11-14-7.dev
4 corrections (HETZNER_V2)
#1: ± MODIFY-TTL testing-2025-11-14-7.dev NS helium.ns.hetzner.de. ttl=(3600->300)
± MODIFY-TTL testing-2025-11-14-7.dev NS hydrogen.ns.hetzner.com. ttl=(3600->300)
± MODIFY-TTL testing-2025-11-14-7.dev NS oxygen.ns.hetzner.com. ttl=(3600->300)
SUCCESS!
#2: + CREATE testing-2025-11-14-7.dev A 127.0.0.1 ttl=300
SUCCESS!
Done. 5 corrections.
```
</details>

Feedback for @jooola and @LKaemmerling:
- The SDK was very useful in getting 80% there! Nice! 🎉 
- Footgun:
- The `result` values are not "up-to-date" after waiting for an
`Action`, e.g. `Zone.AuthoritativeNameservers.Assigned` is not set when
`Client.Zone.Create()` returns and the following "wait" will not update
it.
- Taking a step back here: Waiting for an `Action` with a separate SDK
call does not seem very natural to me. Does the SDK-user need to know
that you are processing operations asynchronous? (Which seems like an
implementation detail to me, something that the SDK could abstrct over.)
Can `Client.Zone.Create()` return the final `Zone` instead of the
intermediate result?
- Features missing compared to the DNS Console, in priority order:
- It is no longer possible to remove your provided name servers from the
root/apex. Use-case: dual-home/multi-home zone with fewer than three
servers from Hetzner. I'm operating one of these and cannot migrate over
until this is fixed.
- Performance regression due to lack of bulk create/modify. E.g. [one of
the test
suites](a71b89e5a2/integrationTest/integration_test.go (L619))
spends about 4.5 minutes on making creating 100 record-sets and then
another 4 minutes for deleting them in sequence again. With your async
API, these are `create 2*100 + delete 2*100 = 400` API calls.
Previously, these were `create 1 + delete 100 = 101` API calls. Are you
planning on adding batch processing again?
- Usability nits
- Compared to other record-set based APIs, upserts for record-sets are
missing. This applies to records of a record-set and the ttl of the
record-set (see separate SDK calls for the cases `diff2.CREATE` vs
`diff2.CHANGE` and two calls in `diff2.CHANGE` for updating the TTL vs
records).
- Some SDK methods return an `Action` (e.g. `Zone.ChangeRRSetTTL()`),
others wrap the `Action` in a struct (`Client.Zone.CreateRRSet()`) --
even when the struct has a single field (`ZoneRRSetDeleteResult`).

---------

Co-authored-by: "Jonas L." <jooola@users.noreply.github.com>
Co-authored-by: "Lukas Kämmerling" <LKaemmerling@users.noreply.github.com>
Co-authored-by: Tom Limoncelli <6293917+tlimoncelli@users.noreply.github.com>
2025-11-30 09:14:54 -05:00
.github HETZNER_V2: Add provider for Hetzner DNS API (#3837) 2025-11-30 09:14:54 -05:00
bin CICD: Detect broken HTML links in the documentation as part of the pipeline (#3439) 2025-03-21 10:56:41 -04:00
build NEW FEATURE: Add SMIMEA support for BIND and deSEC (#3786) 2025-10-10 11:16:13 -04:00
commands BUGFIX: IDN support is broken for domain names (#3845) 2025-11-29 12:17:44 -05:00
docs FEATURE: Optionally disable spfcache.json (#3765) 2025-09-13 12:23:46 -04:00
documentation HETZNER_V2: Add provider for Hetzner DNS API (#3837) 2025-11-30 09:14:54 -05:00
integrationTest HETZNER_V2: Add provider for Hetzner DNS API (#3837) 2025-11-30 09:14:54 -05:00
models BUGFIX: IDN support is broken for domain names (#3845) 2025-11-29 12:17:44 -05:00
pkg BUGFIX: IDN support is broken for domain names (#3845) 2025-11-29 12:17:44 -05:00
providers HETZNER_V2: Add provider for Hetzner DNS API (#3837) 2025-11-30 09:14:54 -05:00
.editorconfig DOCS: expand upon concurrency (#3676) 2025-07-22 10:01:10 -04:00
.git-blame-ignore-revs Add .git-blame-ignore-revs 2025-01-03 13:19:39 -05:00
.gitattributes DOCS: Fix many minor typos (#3752) 2025-09-02 11:00:25 -04:00
.gitignore DOCS: generate smaller tables for feature matrix (2nd try) (#3589) 2025-05-29 13:53:33 -04:00
.goreleaser.yml HETZNER_V2: Add provider for Hetzner DNS API (#3837) 2025-11-30 09:14:54 -05:00
.linkspector.yml DOCS: Linkspector URI fixes (#3625) 2025-06-20 08:39:47 -04:00
.nvmrc CICD: Detect broken HTML links in the documentation as part of the pipeline (#3439) 2025-03-21 10:56:41 -04:00
.prettierrc
Dockerfile Build(deps): Bump alpine from 3.22.1 to 3.22.2 (#3818) 2025-11-03 11:31:31 -05:00
go.mod HETZNER_V2: Add provider for Hetzner DNS API (#3837) 2025-11-30 09:14:54 -05:00
go.sum HETZNER_V2: Add provider for Hetzner DNS API (#3837) 2025-11-30 09:14:54 -05:00
LICENSE
main.go BUG: User-Agent should include DNSControl version (#3653) 2025-07-09 10:56:38 -04:00
OWNERS HETZNER_V2: Add provider for Hetzner DNS API (#3837) 2025-11-30 09:14:54 -05:00
package-lock.json Build(deps): Bump glob from 11.0.1 to 11.1.0 (#3846) 2025-11-21 12:46:12 -05:00
package.json NEW FEATURE: Add SMIMEA support for BIND and deSEC (#3786) 2025-10-10 11:16:13 -04:00
README.md CHORE: Maintainer changes for OPENSRS and DIGITALOCEAN (#3849) 2025-11-24 20:29:43 -05:00
SECURITY.md
staticcheck.conf CHORE: Satisfy Staticcheck and remove unused code (#2331) 2023-05-08 16:49:26 -04:00

DNSControl

StackExchange/dnscontrol/build Google Group PkgGoDev

DNSControl is a system for maintaining DNS zones. It has two parts: a domain specific language (DSL) for describing DNS zones plus software that processes the DSL and pushes the resulting zones to DNS providers such as Route53, Cloudflare, and Gandi. It can send the same DNS records to multiple providers. It even generates the most beautiful BIND zone files ever. It runs anywhere Go runs (Linux, macOS, Windows). The provider model is extensible, so more providers can be added.

Currently supported DNS providers:

  • AdGuard Home
  • Akamai Edge DNS
  • AutoDNS
  • AWS Route 53
  • AXFR+DDNS
  • Azure DNS
  • Azure Private DNS
  • BIND
  • Bunny DNS
  • CentralNic Reseller (CNR) - formerly RRPProxy
  • Cloudflare
  • ClouDNS
  • CSC Global (Experimental)
  • deSEC
  • DigitalOcean
  • DNS Made Easy
  • DNSimple
  • Domainnameshop (Domeneshop)
  • Exoscale
  • Fortigate
  • Gandi
  • Gcore
  • Google DNS
  • Hetzner
  • HEXONET
  • hosting.de
  • Huawei Cloud DNS
  • Hurricane Electric DNS
  • INWX
  • Joker
  • Linode
  • Loopia
  • LuaDNS
  • Microsoft Windows Server DNS Server
  • Mythic Beasts
  • Name.com
  • Namecheap
  • Netcup
  • Netlify
  • NS1
  • Oracle Cloud
  • OVH
  • Packetframe
  • Porkbun
  • PowerDNS
  • Realtime Register
  • RWTH DNS-Admin
  • Sakura Cloud
  • SoftLayer
  • TransIP
  • Vultr

Currently supported Domain Registrars:

  • AWS Route 53
  • CentralNic Reseller (CNR) - formerly RRPProxy
  • CSC Global
  • DNSimple
  • DNSOVERHTTPS
  • Dynadot
  • easyname
  • Gandi
  • HEXONET
  • hosting.de
  • Internet.bs
  • INWX
  • Loopia
  • Name.com
  • Namecheap
  • OpenSRS
  • OVH
  • Porkbun
  • Realtime Register

At Stack Overflow, we use this system to manage hundreds of domains and subdomains across multiple registrars and DNS providers.

You can think of it as a DNS compiler. The configuration files are written in a DSL that looks a lot like JavaScript. It is compiled to an intermediate representation (IR). Compiler back-ends use the IR to update your DNS zones on services such as Route53, Cloudflare, and Gandi, or systems such as BIND.

An Example

dnsconfig.js:

// define our registrar and providers
var REG_NAMECOM = NewRegistrar("name.com");
var r53 = NewDnsProvider("r53")

D("example.com", REG_NAMECOM, DnsProvider(r53),
  A("@", "1.2.3.4"),
  CNAME("www","@"),
  MX("@",5,"mail.myserver.com."),
  A("test", "5.6.7.8")
)

Running dnscontrol preview will talk to the providers (here name.com as registrar and route 53 as the dns host), and determine what changes need to be made.

Running dnscontrol push will make those changes with the provider and my dns records will be correctly updated.

The easiest way to run DNSControl is to use the Docker container:

docker run --rm -it -v "$(pwd):/dns"  ghcr.io/stackexchange/dnscontrol preview

See Getting Started page on documentation site to get started!

Benefits

  • Less error-prone than editing a BIND zone file.
  • More reproducible than clicking buttons on a web portal.
  • Easily switch between DNS providers: The DNSControl language is vendor-agnostic. If you use it to maintain your DNS zone records, you can switch between DNS providers easily. In fact, DNSControl will upload your DNS records to multiple providers, which means you can test one while switching to another. We've switched providers 3 times in three years and we've never lost a DNS record.
  • Apply CI/CD principles to DNS! At StackOverflow we maintain our DNSControl configurations in Git and use our CI system to roll out changes. Keeping DNS information in a VCS means we have full history. Using CI enables us to include unit-tests and system-tests. Remember when you forgot to include a "." at the end of an MX record? We haven't had that problem since we included a test to make sure Tom doesn't make that mistake... again.
  • Adopt (GitOps) PR-based updates. Allow developers to send updates as PRs, which you can review before you approve.
  • Variables save time! Assign an IP address to a constant and use the variable name throughout the file. Need to change the IP address globally? Just change the variable and "recompile."
  • Macros! Define your SPF records, MX records, or other repeated data once and re-use them for all domains.
  • Control Cloudflare from a single source of truth. Enable/disable Cloudflare proxying (the "orange cloud" button) directly from your DNSControl files.
  • Keep similar domains in sync with transforms and other features. If one domain is supposed to be a filtered version of another, this is easy to set up.
  • It is extendable! All the DNS providers are written as plugins. Writing new plugins is very easy.

Installation

DNSControl can be installed via packages for macOS, Linux and Windows, or from source code. See the official instructions.

Via GitHub Actions (GHA)

See dnscontrol-action or gacts/install-dnscontrol.

Deprecation warnings (updated 2025-11-21)

  • REV() will switch from RFC2317 to RFC4183 in v5.0. This is a breaking change. Warnings are output if your configuration is affected. No date has been announced for v5.0. See https://docs.dnscontrol.org/language-reference/top-level-functions/revcompat
  • NAMEDOTCOM, OPENSRS, and SOFTLAYER need maintainers! These providers have no maintainer. Maintainers respond to PRs and fix bugs in a timely manner, and try to stay on top of protocol changes. Interested in being a hero and adopting them? Contact tlimoncelli at stack overflow dot com.

More info at our website

The website: https://docs.dnscontrol.org/

The getting started guide: https://docs.dnscontrol.org/getting-started/getting-started

Stargazers over time

Stargazers over time