# Bare metal without the cloud: host your own authoritative DNS

> Part 3 of the bare-metal series. How to serve your own zones without a cloud DNS service: a hidden primary that signs with DNSSEC, public secondaries on different networks, TSIG-protected transfers, the Knot and NSD settings that trip people up, and the checks to run before you change NS records at the registrar.

- URL: https://ngnext.tech/knowledge/own-authoritative-dns-off-cloud
- Published: 2026-11-26
- Updated: 2026-11-26
- Author: Nishant Gauraw, [NG-NeXT](https://ngnext.tech)
- Tags: dns, authoritative-dns, dnssec, knot-dns, nsd, bare-metal

This is part 3 of the open series on running distributed bare metal with zero cloud dependence on mostly free software. [Part 2](https://ngnext.tech/knowledge/own-validating-dns-resolver-unbound) replaced the public recursive resolver your users ask. This part covers the other half of DNS: the authoritative servers that answer the world for the zones you own.

Many firms leave that half with a cloud provider or a DNS company. That is often a sound choice. It is also a dependency: if the account is suspended, the provider has an outage, or the billing card expires, your names can stop resolving as cached answers expire. Running your own authoritative DNS is a manageable job, as long as the design is right from the start.

## The shape: a hidden primary and public secondaries

A common self-hosted design has two layers:

- **A hidden primary.** One server holds the master copy of each zone, and signs it with DNSSEC. It is not listed in the zone's NS records, so resolvers following the delegation never select it. That alone does not stop someone who learns its address from querying it, so firewall it to talk DNS only with your secondaries.
- **Two or more public secondaries.** These are the servers named in your NS records. They pull the zone from the primary and answer all public queries.

The secondaries learn about changes through NOTIFY ([RFC 1996](https://www.rfc-editor.org/rfc/rfc1996)) and fetch them with zone transfers (AXFR, or incremental IXFR). Transfers and notifies are authenticated with TSIG keys ([RFC 8945](https://www.rfc-editor.org/rfc/rfc8945)). TSIG proves possession of a shared secret, so combine it with address restrictions on both sides, and consider one key per secondary to limit the damage if one leaks. TSIG authenticates; it does not encrypt the transfer.

Why bother hiding the primary? It keeps your signing keys and your editing workflow off the machines that take public traffic, and a public secondary can be rebuilt from the primary at any time. (Moving one to a new address still means updating its address records, any glue at the parent, and the transfer ACLs.)

## Where to put the secondaries

[RFC 2182](https://www.rfc-editor.org/rfc/rfc2182) (BCP 16) is the reference on choosing secondary servers. Its central advice is diversity: the servers for a zone should not share a single point of failure such as one network, one building or one upstream provider. It notes that the DNS rules require at least two servers for every zone, and says "it is recommended that three servers be provided for most organisation level zones." With a hidden primary, that means two public secondaries as a minimum and three as the target, in different sites, on different networks. Two servers in the same rack on the same uplink share one failure domain, whatever the count says.

You can mix ownership. A secondary on your own hardware in each of two locations is the purest version of this series. A third secondary at a DNS provider that accepts zone transfers from your hidden primary is a reasonable hedge: the provider gets a copy of the zone and a transfer key, while the master data and the DNSSEC private keys stay with you.

## Choosing the software

Free, mature options, all actively maintained:

- [Knot DNS](https://www.knot-dns.cz/) (CZ.NIC): authoritative-only, with built-in automatic DNSSEC signing and key rollover. A good fit for the primary.
- [NSD](https://nlnetlabs.nl/projects/nsd/about/) (NLnet Labs): authoritative-only and deliberately simple. A good fit for secondaries.
- [BIND 9](https://www.isc.org/bind/) (ISC): authoritative and recursive service in one package, with automatic signing through `dnssec-policy`.
- [PowerDNS Authoritative](https://doc.powerdns.com/authoritative/): several backends, including databases and plain zone files, and a built-in HTTP API, useful when other systems create records.

Running different software on the primary and the secondaries also reduces the chance that one implementation bug takes out every server at once. It does not protect against bad zone data or a signing failure, which every secondary will faithfully serve.

## A minimal hidden primary with Knot DNS

The configuration below uses documentation addresses. The Knot and NSD pair in this post was checked end to end (TSIG-signed NOTIFY, IXFR and AXFR, and DNSSEC signing) with Knot DNS 3.4.6 and NSD 4.12.0 on Debian 13, using loopback addresses. Generate a TSIG key first:

```
keymgr -t xfr-key hmac-sha256
```

That prints a `key:` section to paste into the configuration (and a comment line that also contains the secret, so do not paste its output into tickets or chat). Then, in `knot.conf`:

```
server:
    listen: 192.0.2.53@53

key:
  - id: xfr-key
    algorithm: hmac-sha256
    secret: <base64 secret from keymgr>

remote:
  - id: sec1
    address: 198.51.100.10
    key: xfr-key
  - id: sec2
    address: 203.0.113.20
    key: xfr-key

acl:
  - id: secondaries
    address: [198.51.100.10, 203.0.113.20]
    key: xfr-key
    action: transfer

zone:
  - domain: example.com
    file: example.com.zone
    notify: [sec1, sec2]
    acl: secondaries
    dnssec-signing: on
    zonefile-sync: -1
    zonefile-load: difference-no-serial
    journal-content: all
```

With `dnssec-signing: on` and no explicit policy, Knot uses its default signing policy and manages keys itself. A relative `file:` is read from Knot's storage directory.

The last three lines matter more than they look. By default Knot writes the zone, signatures included, back into the zone file, so the file you edit by hand is replaced with a machine dump and your next edit can be lost or conflict with it. With `zonefile-sync: -1` Knot stops writing the file automatically (a forced `knotc zone-flush` still would); with `zonefile-load: difference-no-serial` and `journal-content: all` it applies your edits as differences on `knotc zone-reload`, re-signs, raises the serial itself and notifies the secondaries. This is the workflow of [Example 4 in the Knot operation manual](https://www.knot-dns.cz/docs/latest/html/operation.html#example-4), and the options are defined in the [reference](https://www.knot-dns.cz/docs/latest/html/reference.html); read both before choosing a workflow. The manual warns that this mode is not suitable if the zone is also changed by dynamic updates or `knotc`, and that the journal must be sized for it.

Check the configuration before you start it:

```
knotc conf-check
```

Firewall the primary so that only the secondaries can reach it, and only you can reach its management.

## A secondary with NSD

On each secondary, in `nsd.conf`:

```
key:
    name: "xfr-key"
    algorithm: hmac-sha256
    secret: "<same base64 secret>"

zone:
    name: "example.com"
    zonefile: "example.com.zone"
    allow-notify: 192.0.2.53 xfr-key
    request-xfr: 192.0.2.53 xfr-key
```

Here `192.0.2.53` stands for the hidden primary. The `zonefile:` line lets NSD keep the transferred zone on disk (written periodically, hourly by default), so after a restart it can serve the zone without waiting for a new transfer, as long as the zone has not expired. Run `nsd-checkconf /etc/nsd/nsd.conf` before restarting, and keep the TSIG secret readable only by the service account.

One error to recognise: if the secondary has several addresses and sends its transfer request from one the primary's ACL does not list, the transfer fails even though the key is right. NSD logs it like this:

```
error: xfrd: zone example.com received error code SERVER NOT AUTHORITATIVE FOR ZONE from 192.0.2.53@53
error: xfrd: zone example.com, from 192.0.2.53@53: no tsig in first packet of reply
```

In this case, with Knot DNS 3.4.6 as the primary, the refusal came back unsigned, so the second line is a symptom of the first, not a key problem. Add the secondary's real source address to the ACL, or pin it with `outgoing-interface:` in the NSD zone. A good transfer logs "TSIG verified with key xfr-key".

## SOA timers that suit a hidden primary

The SOA record's expire value says how long a secondary keeps answering for a zone it cannot refresh from the primary, counted from its last successful refresh. With a hidden primary, that sets an upper bound on how long the primary can be down. With DNSSEC, the remaining validity of the signatures can be the shorter limit. [RIPE-203](https://www.ripe.net/publications/docs/ripe-203/), a long-standing set of recommendations for SOA values, suggests an expire of 3600000 seconds (1000 hours, about six weeks). A short expire, such as a few hours, means a weekend outage of the primary takes the whole domain down when the secondaries give up.

## Checks before you switch the NS records

Run these against every public secondary, not just one:

```
dig @198.51.100.10 example.com SOA +norec
dig @203.0.113.20  example.com SOA +norec
dig @198.51.100.10 example.com DNSKEY +dnssec +norec
```

The SOA serials should match the primary's, and the header should read `flags: qr aa` (`aa` is the authoritative-answer flag; do not add `+short`, which hides the header). The DNSKEY answer should include RRSIG records. Then check the zone as a whole with an independent tool such as [Zonemaster](https://zonemaster.net/) or [DNSViz](https://dnsviz.net/).

If your nameservers are named inside the zone they serve (`ns1.example.com` for `example.com`), the parent zone needs glue records with their addresses. You set those at the registrar, together with the NS records.

## DNSSEC: the step that breaks domains

Signing the zone is automatic. Publishing the DS record in the parent zone is a separate step. The DS must match a key your primary is actually using. If the parent publishes a DS (with a supported algorithm) that matches no key the zone is signed with, validating resolvers, including the ones from part 2, return `SERVFAIL` for names in your domain. No DS at all simply means the zone is treated as unsigned.

The safe order:

1. Move the NS records to your secondaries with the zone signed but no DS at the parent. Keep the old servers answering while caches still point at them, and confirm that the parent and the zone itself list the new NS set. Then wait until the old NS records' TTLs, at the parent and in the zone, have passed, so no resolver is still asking the old servers.
2. Read the DS from your primary (`keymgr example.com ds` in Knot), and check that the KSK it belongs to is published in the DNSKEY set every secondary serves.
3. Submit the DS at the registrar. Some registries and registrars also support automated updates through CDS and CDNSKEY records ([RFC 7344](https://www.rfc-editor.org/rfc/rfc7344), [RFC 8078](https://www.rfc-editor.org/rfc/rfc8078)); check whether yours does before relying on it.
4. Re-run the validation check after the DS appears in the parent zone. Before moving the delegation, a test that queries the new servers directly (Zonemaster has an undelegated mode for this) catches mistakes while the old service still carries the traffic.

If you are moving a zone that is already signed by a provider, the change has to keep a valid chain of trust throughout. Plan it as a key rollover between operators, or go insecure for a while: remove the DS at the parent, confirm the removal is visible there, wait out the DS TTL while the old signed service keeps answering, move the delegation, let the old NS and DNSKEY records expire from caches, verify the new signed service, and only then publish the new DS. Rushing this step is a well-known way to take a domain offline for every validating resolver.

## Running it

Monitor from outside your own network: query every public secondary for the SOA serial on a schedule and alert when one lags or stops answering. Watch DNSSEC signature expiry too: if fresh signatures stop reaching the secondaries, signed records start failing validation as their last signatures expire. Response rate limiting, which Knot, NSD and BIND all support in some form, reduces the use of your servers as amplifiers in reflection attacks.

Next in the series: designing offsite backups without a hyperscaler.

The know-how in this series stays open. If you would rather have the DNS design, the DNSSEC migration and the rest of a cloud exit planned and built with you, [NG-NeXT](https://ngnext.tech) does consulting and turnkey builds. Tell us what you run today through the [contact page](https://ngnext.tech/contact).

— Nishant Gauraw, Founder and CEO, [NG-NeXT Tech](https://ngnext.tech)

## Updated and author

Last updated 2026-11-26 by Nishant Gauraw, [NG-NeXT](https://ngnext.tech).
