# DNS

> The three ways Berth handles a domain's DNS (elsewhere with checking, through a provider's API including RFC 2136, or on its own BIND server with DNSSEC), plus custom records, secondaries, zone import, DNS templates and locks per package, and the DNS lock until switchover.

Source: https://www.berthpanel.app/library/dns/ · Category: dns · Updated: 2026-10-30

A website and its mail only work when the domain's DNS points to the right place: A and AAAA records for the site, MX, SPF, DKIM and DMARC for mail. Berth knows exactly which records each domain needs, because it set up the site and the mail. What it does with that knowledge depends on where the DNS lives, and you choose that per domain.

## Three ways to handle DNS

| Mode | Who writes the records | When to use it |
|---|---|---|
| **Elsewhere, with checking** | You, at your DNS host. The panel lists the records and checks them. | The DNS stays with a registrar or team you don't control. |
| **Through a DNS provider's API** | The panel, at Cloudflare, TransIP, Hetzner, deSEC, OXXA, Route 53, DigitalOcean, or your own nameserver. | You keep your provider but want the panel to keep records right. |
| **On this server** | The panel, in its own authoritative BIND server, with DNSSEC. | You want everything in one place, or you run your own nameservers. |

The modes can be mixed: one domain on Cloudflare, another on the server's own DNS, a third left alone. The domain's *DNS* page shows where its DNS is, which records it needs, and whether they are right.

## DNS elsewhere, with checking

This is the default. The domain page lists what must be set at your DNS host: A and AAAA for the domain and its aliases and, with mail on, MX, SPF, DKIM, DMARC and the other [mail records](https://www.berthpanel.app/library/mail-authentication/). Each record has a copy button. **Check the DNS records** asks public resolvers and marks each record as correct, missing or different.

```bash
berth domain dns --domain example.com --check
```

For a wildcard certificate while DNS stays elsewhere, you can delegate only the certificate challenge to the server with a single record; see [Certificates](https://www.berthpanel.app/library/certificates/).

## DNS through a provider's API

### Adding an account

1. Go to *Domains → DNS providers* and add an account under **Add account**.
2. Choose the provider and enter its API credentials:
   - **Cloudflare**: an API token with Zone:Read and DNS:Edit.
   - **Hetzner, deSEC, DigitalOcean**: a token with write access.
   - **TransIP**: your login and the key pair from TransIP's control panel (PEM), without an IP whitelist or with this server's address on it.
   - **OXXA**: the API user and API password.
   - **Amazon Route 53**: the access key ID and the secret access key.
3. Click **Add and test**. The panel tests the credentials straight away and reports which zones it can see.

An administrator's account can be linked to any domain; a customer can add their own account, which can only be linked to their own domains.

```bash
berth dns account-add --name cf --provider cloudflare --token-file token.txt
berth dns account-add --name tip --provider transip --login acme --key-file transip.pem
berth dns accounts
```

### Linking a domain and publishing records

1. On the domain's *DNS* page, under *Link with your DNS provider*, choose the account. The panel finds the zone itself.
2. Keep *Update the address (A/AAAA) automatically* on, so A and AAAA follow the server when its address changes.
3. Click **Set records at the provider**.

```bash
berth dns link --domain example.com --account 3 --auto
berth dns records --domain example.com --zone     # needed vs. present, plus the whole zone
berth dns apply --domain example.com
```

The panel only manages its own records: addresses, MX, SPF, DKIM, DMARC, MTA-STS and autodiscover. Other TXT and CAA values, such as a Google site verification, are left alone; for SPF and DMARC the panel replaces the value rather than adding a second record. The page also lists everything the provider has in the zone, marking each record as managed by the panel or your own. A linked domain can also get wildcard certificates through DNS-01.

OXXA only supports A, AAAA, CNAME, MX and TXT, so records of other types (such as the SRV record for autodiscover) are skipped there.

### Your own nameserver over RFC 2136

An administrator can link BIND, Knot or PowerDNS directly: choose *Own nameserver (RFC 2136, TSIG)*. The panel updates zones with dynamic updates (RFC 2136) and reads them with a zone transfer (AXFR), both over TCP and signed with TSIG. Enter the nameserver (host or host:port), the TSIG key name as login, the secret in base64 as `tsig-keygen` creates it, the algorithm (`hmac-sha256` by default, or `hmac-sha384`, `hmac-sha512`) and the zones the panel may update.

The key needs permission to update and transfer those zones. In BIND, for example:

```text
zone "example.com" {
    type primary;
    file "example.com.zone";
    update-policy { grant berth-key zonesub ANY; };
    allow-transfer { key berth-key; };
};
```

```bash
berth dns account-add --name ns --provider rfc2136 --server ns1.example.nl \
  --login berth-key --token-file tsig.secret --algorithm hmac-sha256 --zones "example.com example.nl"
```

## DNS on this server

Berth can be the authoritative nameserver for your domains, using BIND with DNSSEC.

### Switching on the DNS server

On *DNS providers*, open the card *DNS on this server*, enter the nameserver names (the first goes into the SOA) and the hostmaster address, and switch it on. The nameserver names must point to this server or to a secondary, with glue records at your registrar where needed.

```bash
berth dns server --enable --ns ns1.example.nl,ns2.example.nl --hostmaster hostmaster@example.nl
berth dns server                       # show
```

`--listen` limits the addresses BIND listens on (by default those of the server). DNSSEC is on by default; `--no-dnssec` leaves zones unsigned.

### Moving a domain's DNS here

1. On the domain's *DNS* page, click **This domain's DNS on this server**, or run `berth dns zone --domain example.com --on`.
2. The zone is filled with every record the panel knows: the website and its aliases, mail with SPF, DKIM and DMARC, autodiscover, and the package's DNS template if it has one.
3. At your registrar, point the domain's nameservers to this server and add the **DS record** the page shows under *DS record for your registrar (DNSSEC)*.

From then on, changes go along by themselves: a new alias, mail switched on, a changed address. To go back, set the nameservers at the registrar back first, then click **DNS external again** or `berth dns zone --domain example.com --off`.

### DNSSEC

Zones are signed automatically with a BIND `dnssec-policy`: BIND creates and rolls over the keys. You only add the DS record at the registrar once. With DNSSEC in place you can also publish [DANE](https://www.berthpanel.app/library/mail-authentication/#dane) records for the mail server.

### Custom records

The domain's *DNS* page lists the zone's records with their origin: *panel* (from the panel) or *own* (your own). Under *Add record*, add A, AAAA, CNAME, MX, TXT, SRV, CAA, TLSA or NS records. `@` is the domain itself; a TTL of 0 means the default. A custom record with the same name and type replaces the panel's record.

```bash
berth dns record-add --domain example.com --name www --type CNAME --value example.com --ttl 3600
berth dns record-add --domain example.com --name @ --type MX --value "20 backup-mx.example.net"
berth dns record-remove --domain example.com --id 17
```

### Importing a zone from the previous provider

Under *Import zone file from the previous DNS provider*, paste the old zone in BIND notation, for example an export from your old provider. Records the panel sets itself (SOA, NS, the domain's addresses and mail, SPF, its own DKIM key), records that are already identical and records that would conflict are skipped. `$INCLUDE` is not supported.

```bash
berth dns zone-import --domain example.com --file old-zone.txt
```

### Secondary nameservers

Secondary nameservers receive a NOTIFY on every change and may transfer the zones, either by IP address or with a TSIG key. Add their addresses to the server settings, and show the key for the secondary's configuration with *Show key* on the TSIG card.

```bash
berth dns server --enable --ns ns1.example.nl,ns2.example.net --secondary 198.51.100.53
berth dns tsig        # the key in BIND format; secret, run as root
```

### A bad zone never goes live

Like every configuration in Berth, a zone is rendered to a staging file and checked with `named-checkzone` before it replaces the live one (see [How changes go live](https://www.berthpanel.app/library/how-changes-go-live/)). If a change does not pass, the previous version of the zone keeps being served and the domain's *DNS* page says why.

## DNS templates and locks per package

A package can add records to every domain on it, and can stop customers from editing DNS themselves. Both are under *DNS template* when you edit a package (see [Customers and packages](https://www.berthpanel.app/library/customers-and-packages/)).

- **DNS template**: one record per line as `name type value`, without quotes; lines starting with `#` are comments. `@` is the domain, and `{domain}` in the value is replaced by the domain name. The records go into the server's own zones and to linked providers. A domain's own record takes precedence.
- **No custom DNS records for the customer**: the customer cannot add or remove records or import a zone; the administrator and the reseller still can.

```bash
cat > dns-template.txt <<'EOF'
shop CNAME shops.example.net
status CNAME status.example.net
@ TXT hosted-by=example.net site={domain}
EOF
berth plan set --name basic --dns-template-file dns-template.txt --dns-locked
```

## DNS lock until switchover

When you move domains from another server, the DNS still points to the old server until the switchover. During that time the panel must not move addresses or MX at the providers, or live sites and mail would jump to a server that is not ready.

The lock on *DNS providers* (card *Lock until switchover*) does exactly that. While it is on, the panel only sets DKIM keys and certificate challenges at the providers; addresses, MX, SPF, MTA-STS and CNAMEs stay as they are, and the domain's *DNS* page marks them as locked. After a subscription has switched over, the lock no longer applies to its domains. The first migration import switches the lock on by itself, unless you have set it before. Switch it off yourself once the whole migration is done.

```bash
berth dns lock          # show
berth dns lock --on
berth dns lock --off
```

See [Migration overview](https://www.berthpanel.app/library/migration-overview/) for how the switchover itself works without customers touching DNS.
