241 lines
9.5 KiB
Markdown
241 lines
9.5 KiB
Markdown
# Zone transfer variants (Primary ↔ Secondary)
|
||
|
||
Examples use documentation names and addresses: zones `example.com`, `example.net`,
|
||
`example.org`; primary `192.0.2.10` / `2001:db8::10`; secondaries `198.51.100.20`,
|
||
`198.51.100.21`. Keys are optional; when used, secrets are references (`file:`/`env:`)
|
||
or BIND key files included from `keys.d/`.
|
||
|
||
## Is a TSIG key required?
|
||
|
||
**No.** The default – in the example configurations, in `easydns zone create` and below –
|
||
is **authorisation by IP address only**, exactly like BIND's
|
||
`allow-transfer { 198.51.100.20; }; also-notify { 198.51.100.20; };`. A TSIG key is an
|
||
**optional** extra layer that you can add at any time without changing anything else.
|
||
|
||
When the key is worth adding:
|
||
|
||
* it authenticates both directions (the secondary verifies that the zone really came from
|
||
the primary – IP-only transfers can be spoofed or altered on the path over the Internet),
|
||
* it protects against misconfigured or shared NAT addresses,
|
||
* it signs NOTIFY.
|
||
|
||
| Situation | Suggested setup |
|
||
|---|---|
|
||
| Primary and secondary in the same private network / VPN / WireGuard tunnel | IP ACL (default) |
|
||
| Your own servers talking over the public Internet | IP ACL; optionally + TSIG |
|
||
| Third-party secondary service with many / changing addresses | TSIG (the IP list is impractical) |
|
||
| DNSSEC-signed zones | IP ACL is enough – the data is verifiable anyway |
|
||
|
||
`easydns check-config` does not require keys. It reports an error only for a dangerous
|
||
combination: transfers open to `any` address without a key.
|
||
|
||
### How EasyDNS evaluates access
|
||
|
||
| Side | Setting | Rule |
|
||
|---|---|---|
|
||
| Primary – AXFR/IXFR | `transfer_acl` only (default style) | client IP must be in the ACL |
|
||
| | `transfer_tsig_key` only | valid TSIG with that key, any IP |
|
||
| | both | valid TSIG **and** IP in the ACL |
|
||
| | neither | refused (default deny) |
|
||
| Secondary – NOTIFY | `allow_notify` (default: the `primaries` addresses) | source IP must match |
|
||
| | optional `transfer.tsig_key` | NOTIFY must be signed with that key; a correctly signed NOTIFY is accepted from any address |
|
||
| Secondary – refresh | optional `transfer.tsig_key` | SOA query, IXFR and AXFR are signed and every response message is verified |
|
||
|
||
NOTIFY only *triggers* a refresh; the secondary always checks the SOA serial on the
|
||
primaries it is configured with, so a forged NOTIFY cannot inject data.
|
||
|
||
---
|
||
|
||
## Variant 1 – IP only (default, no key)
|
||
|
||
Primary (`192.0.2.10`):
|
||
```yaml
|
||
zones:
|
||
- name: example.com
|
||
type: primary
|
||
file: zones/primary/example.com.zone # = /etc/easydns/data/zones/primary/example.com.zone
|
||
transfer_acl: ["198.51.100.20/32", "198.51.100.21/32"]
|
||
notify: ["198.51.100.20:53", "198.51.100.21:53"]
|
||
```
|
||
Secondary (`198.51.100.20`):
|
||
```yaml
|
||
zones:
|
||
- name: example.com
|
||
type: secondary
|
||
primaries: ["192.0.2.10:53"] # NOTIFY accepted from this address by default
|
||
transfer: { prefer: ixfr, fallback_axfr: true }
|
||
```
|
||
The same with the CLI on the primary:
|
||
`easydns zone create example.com --ns ns1.example.com=192.0.2.10 --ns ns2.example.net --allow-transfer 198.51.100.20 --notify 198.51.100.20`.
|
||
Restricting port 53/TCP on the primary to the secondaries with a firewall is a good extra.
|
||
|
||
## Variant 2 – optional: IP ACL + TSIG key
|
||
|
||
Add the key on both sides; everything else stays as in variant 1.
|
||
|
||
Primary:
|
||
```yaml
|
||
keys:
|
||
- { name: xfr-key, algorithm: hmac-sha256, secret: "file:/etc/easydns/keys/xfr.secret" }
|
||
# or a key file copied from BIND: include: ["keys.d/*.conf"]
|
||
zones:
|
||
- name: example.com
|
||
type: primary
|
||
file: zones/primary/example.com.zone
|
||
transfer_acl: ["198.51.100.20/32", "198.51.100.21/32"]
|
||
transfer_tsig_key: xfr-key # optional
|
||
notify: ["198.51.100.20:53", "198.51.100.21:53"]
|
||
notify_tsig_key: xfr-key # optional
|
||
```
|
||
Secondary:
|
||
```yaml
|
||
keys:
|
||
- { name: xfr-key, algorithm: hmac-sha256, secret: "file:/etc/easydns/keys/xfr.secret" }
|
||
zones:
|
||
- name: example.com
|
||
type: secondary
|
||
primaries: ["192.0.2.10:53"]
|
||
transfer: { prefer: ixfr, fallback_axfr: true, tsig_key: xfr-key } # optional
|
||
```
|
||
Generate a secret: `head -c 32 /dev/urandom | base64 > /etc/easydns/keys/xfr.secret`.
|
||
|
||
## Variant 3 – optional: TSIG only (secondary with changing addresses)
|
||
|
||
```yaml
|
||
# primary
|
||
- name: example.com
|
||
type: primary
|
||
file: zones/primary/example.com.zone
|
||
transfer_tsig_key: xfr-key # no transfer_acl: any address with a valid key
|
||
notify: ["203.0.113.5:53"]
|
||
notify_tsig_key: xfr-key
|
||
```
|
||
|
||
## Variant 4 – several primaries (failover)
|
||
|
||
```yaml
|
||
- name: example.com
|
||
type: secondary
|
||
primaries: ["192.0.2.10:53", "192.0.2.11:53", "[2001:db8::10]:53"] # tried in order
|
||
allow_notify: ["192.0.2.10/32", "192.0.2.11/32", "2001:db8::10/128"]
|
||
transfer: { prefer: ixfr } # add tsig_key: xfr-key if you use a key
|
||
```
|
||
The first primary that answers the SOA query is used; on failure the next one is tried.
|
||
|
||
## Variant 5 – hidden primary
|
||
|
||
The primary is not listed in the zone's NS records and is reachable only by the
|
||
secondaries (firewall). Public servers are only the secondaries.
|
||
|
||
```yaml
|
||
# hidden primary – listens only on the management network
|
||
server: { mode: primary, listen: ["10.0.0.10:53"] }
|
||
zones:
|
||
- name: example.com
|
||
type: primary
|
||
file: zones/primary/example.com.zone
|
||
transfer_acl: ["10.0.0.20/32", "10.0.0.21/32"]
|
||
notify: ["10.0.0.20:53", "10.0.0.21:53"]
|
||
resolution: { default: refuse }
|
||
```
|
||
The zone file's NS records list only the public secondaries; SOA MNAME may stay the
|
||
hidden name (it is informational).
|
||
|
||
## Variant 6 – chained secondaries (primary → secondary → secondary)
|
||
|
||
A secondary can be the source for other secondaries:
|
||
```yaml
|
||
# middle server: secondary of 192.0.2.10, primary-like source for 198.51.100.30
|
||
- name: example.com
|
||
type: secondary
|
||
primaries: ["192.0.2.10:53"]
|
||
transfer_acl: ["198.51.100.30/32"]
|
||
notify: ["198.51.100.30:53"] # NOTIFY is sent after each successful update
|
||
# optional keys: transfer: { tsig_key: upstream-key }, transfer_tsig_key / notify_tsig_key: downstream-key
|
||
```
|
||
IXFR works along the chain (the middle server keeps its own journal).
|
||
|
||
## Variant 7 – polling only (no NOTIFY)
|
||
|
||
Omit `notify` on the primary. Secondaries refresh every SOA REFRESH seconds and retry every
|
||
RETRY seconds; set them in the zone's SOA accordingly (e.g. `REFRESH 300 RETRY 60`).
|
||
`easydns zones sync example.com` forces an immediate refresh.
|
||
|
||
## Variant 8 – BIND as primary, EasyDNS as secondary
|
||
|
||
Without a key (default) – BIND side:
|
||
```
|
||
zone "example.com" {
|
||
type primary; file "/var/named/example.com.zone";
|
||
allow-transfer { 198.51.100.20; };
|
||
also-notify { 198.51.100.20; };
|
||
notify-source 192.0.2.10; // the address EasyDNS expects NOTIFY from
|
||
ixfr-from-differences yes; // IXFR also for file-edited zones
|
||
};
|
||
```
|
||
and on EasyDNS `primaries: ["192.0.2.10:53"]` with no `tsig_key`.
|
||
|
||
Optional, with a key – BIND side:
|
||
```
|
||
key "xfr-key" { algorithm hmac-sha256; secret "<base64 from xfr.secret>"; };
|
||
server 198.51.100.20 { keys { xfr-key; }; }; // NOTIFY to EasyDNS is signed
|
||
options { notify-source 192.0.2.10; }; // the address EasyDNS expects
|
||
zone "example.com" {
|
||
type primary; file "/var/named/example.com.zone";
|
||
allow-transfer { key xfr-key; };
|
||
also-notify { 198.51.100.20 key xfr-key; };
|
||
ixfr-from-differences yes; // IXFR also for file-edited zones
|
||
};
|
||
```
|
||
The same key file can be copied to EasyDNS unchanged (`/etc/easydns/keys.d/xfr.conf`,
|
||
included by the default configuration) and used as `tsig_key: xfr-key`.
|
||
Details and checks: [migration-from-bind.md](migration-from-bind.md).
|
||
|
||
## Variant 9 – EasyDNS as primary, BIND as secondary
|
||
|
||
Without a key: EasyDNS `transfer_acl: ["<BIND IP>/32"]`, `notify: ["<BIND IP>:53"]`; BIND:
|
||
`zone "example.com" { type secondary; primaries { 192.0.2.10; }; file "secondary/example.com.db"; };`
|
||
|
||
Optional, with a key:
|
||
```
|
||
key "xfr-key" { algorithm hmac-sha256; secret "<same base64>"; };
|
||
server 192.0.2.10 { keys { xfr-key; }; };
|
||
zone "example.com" {
|
||
type secondary;
|
||
primaries { 192.0.2.10 key xfr-key; };
|
||
file "secondary/example.com.db";
|
||
};
|
||
```
|
||
|
||
## Variant 10 – optional: different keys per zone / per secondary
|
||
|
||
Keys are per zone, so different customers or providers can have separate secrets:
|
||
```yaml
|
||
keys:
|
||
- { name: provider-a, secret: "file:/etc/easydns/keys/provider-a.secret" }
|
||
- { name: provider-b, secret: "file:/etc/easydns/keys/provider-b.secret" }
|
||
zones:
|
||
- { name: example.com, type: primary, file: zones/primary/example.com.zone, transfer_tsig_key: provider-a, notify: ["198.51.100.20:53"], notify_tsig_key: provider-a }
|
||
- { name: example.net, type: primary, file: zones/primary/example.net.zone, transfer_tsig_key: provider-b, notify: ["203.0.113.7:53"], notify_tsig_key: provider-b }
|
||
```
|
||
|
||
## Key rotation (only when you use keys)
|
||
|
||
A zone accepts one transfer key at a time, so rotate in this order:
|
||
1. add the new key (`xfr-key-2`) to `keys:` on both sides and reload;
|
||
2. switch the **secondary** to `tsig_key: xfr-key-2` and the **primary** to
|
||
`transfer_tsig_key: xfr-key-2` / `notify_tsig_key: xfr-key-2` in one maintenance step
|
||
(reload both; a failed refresh in between is retried after RETRY and the zone keeps
|
||
being served);
|
||
3. remove the old key.
|
||
To avoid the short window, temporarily use variant 1 (IP only) during the switch.
|
||
|
||
## Splitting zone definitions into files
|
||
|
||
With many zones keep one file per zone or per customer:
|
||
```yaml
|
||
# /etc/easydns/config.yaml
|
||
include: ["zones.d/*.yaml"]
|
||
```
|
||
See [configuration.md](configuration.md#include-files).
|