Files
EasyDNS/docs/migration-from-bind.md
2026-11-23 09:31:05 +01:00

197 lines
12 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Migrating from BIND 9
This guide covers the common BIND deployments. In every case the safe pattern is the
same: **run EasyDNS next to BIND, compare answers, switch traffic, keep BIND ready for
rollback.** Commands use the long tool names; short names (`ed`, `ediff`, …) work too.
## 0. Inventory and translation table
```bash
named-checkconf -p > /tmp/named.full.conf # flattened BIND config (all includes)
rndc zonestatus example.com # type, serial, files, signing
```
| BIND (`named.conf`) | EasyDNS (`config.yaml`) |
|---|---|
| `listen-on port 53 { 192.0.2.1; };` / `listen-on-v6` | `server.listen: ["192.0.2.1:53", "[2001:db8::1]:53"]` |
| `directory "/var/named";` | `server.data_dir` (default install: `/etc/easydns/data`); zone `file:` paths are relative to it (`zones/primary/example.com.zone`) |
| `key "xfr" { algorithm hmac-sha256; secret "…"; };` | copy the BIND key file unchanged to `/etc/easydns/keys.d/` (included by default), or `keys: [ { name: xfr, secret: "file:…" } ]` |
| `acl lan { 10.0.0.0/8; };` | `acls: { lan: ["10.0.0.0/8"] }`, referenced as `acl:lan` |
| `zone "x" { type master; file "…"; };` | `zones: [ { name: x, type: primary, file: … } ]` |
| `allow-transfer { 192.0.2.20; };` | `transfer_acl: ["192.0.2.20/32"]` |
| `allow-transfer { 192.0.2.20; key xfr; };` | `transfer_acl: ["192.0.2.20/32"]` + optional `transfer_tsig_key: xfr` (both must match when the key is set) |
| `also-notify { 192.0.2.20; };` / `notify yes;` | `notify: ["192.0.2.20:53"]` (+ optional `notify_tsig_key: xfr`) |
| `zone "x" { type slave; masters { 192.0.2.10; }; };` | `type: secondary`, `primaries: ["192.0.2.10:53"]` (+ optional `transfer: { tsig_key: xfr }` for `masters { … key xfr; }`) |
| `allow-notify { … };` | `allow_notify: [...]` (default: the primaries' addresses) |
| `allow-update { 192.0.2.7; };` | `update_acl: ["192.0.2.7"]` (alias `allow_update`) – updates without a key |
| `allow-update { key ddns; };` | `update_keys: [ddns]`, optional `update_acl` |
| `update-policy { grant k name x. TXT; … };` | `update_policy: ["grant k name x. TXT", …]` – same syntax |
| `recursion yes; allow-recursion { lan; };` | `recursion: { enabled: true, allowed_clients: ["acl:lan"] }` + `resolution: { default: recursive }` |
| `forwarders { 1.1.1.1; }; forward only;` | `upstreams: { servers: ["1.1.1.1"] }` + `resolution: { default: forward }` |
| `forward first;` | `resolution: { default: forwardthenrecursive }` |
| `zone "corp" { type forward; forwarders { 10.0.0.53; }; };` | `forward_zones: [ { domain: corp, upstreams: ["10.0.0.53"] } ]` |
| `dnssec-validation auto;` | `recursion.dnssec_validation: true` (built-in IANA root anchors) |
| `trust-anchors { … initial-ds …; };` | `recursion.trust_anchors: file` with DS/DNSKEY records (static; no RFC 5011) |
| `view "lan" { match-clients { lan; }; zone … };` | `resolution.views: [ { name: lan, clients: ["acl:lan"] } ]` + `zones[].views: [lan]` |
| `response-policy { zone "rpz"; };` | `policy.blocklists` (convert the RPZ, see below) |
| `rate-limit { responses-per-second 10; };` | `rate_limit` (per client, not per response) |
| `statistics-channels` | `metrics.listen` (Prometheus) + `GET /api/v1/stats` |
| `controls` / `rndc` | REST API on loopback + `easydns` (table below) |
| `version "none";` | default: `version.bind` is REFUSED unless `server.identity` is set |
| rndc / BIND tool | EasyDNS |
|---|---|
| `rndc reload` / `rndc reconfig` | `easydns reload` or `systemctl reload easydns` (SIGHUP) |
| `rndc reload zone` | `easydns reload` (only changed zones are re-published) |
| `rndc retransfer zone` / `rndc refresh zone` | `easydns zones sync zone` |
| `rndc notify zone` | `easydns zones notify zone` |
| `rndc flush` / `rndc flushname x` | `easydns cache clear` / `easydns cache clear --domain x` |
| `rndc status`, `rndc zonestatus` | `easydns status`, `easydns zones show zone` |
| `named-checkconf` / `named-checkzone` | `econf check` / `ezone check FILE --origin ZONE` |
| `dig`, `host`, `nslookup`, `delv`, `dig +trace` | `easydig`, `easyhost`, `easynslookup`, `easydnssec`, `easytrace` |
| `dnssec-keygen` / `dnssec-dsfromkey` | `easydns dnssec keygen` / `easydns dnssec ds` |
### Zone file compatibility
BIND zone files are read as they are ($ORIGIN, $TTL, $INCLUDE, parentheses, comments,
relative names, all common types, DNSSEC types and RFC 3597 `\#` syntax). Check every
file first:
```bash
for f in /var/named/*.zone; do easyzone check "$f" --origin "$(basename "$f" .zone)"; done
```
Not supported: **`$GENERATE`** (expand it first, e.g. with `named-compilezone -o - zone file`,
which writes a fully expanded zone), **DNAME** records, and DNSSEC/RFC 3597 records inside
`$INCLUDE`d files (move them into the main file). Files without `$TTL` get 3600 s for records
without an explicit TTL (BIND uses the SOA MINIMUM and warns) – add `$TTL` to be explicit.
Zones changed through the EasyDNS API/DDNS are rewritten in canonical form (comments are lost).
## 1. Authoritative primary (hidden or public master)
1. Copy zone files and TSIG secrets; translate the zone statements (table above).
2. Validate: `easyconf check /etc/easydns/config.yaml`.
3. Start EasyDNS on a test port (e.g. `--listen 127.0.0.1:5300`) on the BIND host or a new host.
4. Compare every zone with BIND (order-insensitive, TTLs reported separately):
```bash
for z in example.com example.net; do
easydig @127.0.0.1 -p 53 $z AXFR -y hmac-sha256:xfr:$SECRET --json > /tmp/bind.$z.json
easydig @127.0.0.1 -p 5300 $z AXFR -y hmac-sha256:xfr:$SECRET --json > /tmp/easy.$z.json
done
easydiff www.example.com A @127.0.0.1:53 @127.0.0.1:5300
```
5. Cut over: stop BIND, start EasyDNS on port 53 (same IPs → secondaries and the registry
need no change). Make sure the **SOA serial does not go backwards** – keep the files'
serials or raise them.
6. Secondaries (BIND or others) keep working: EasyDNS answers SOA/IXFR/AXFR with TSIG and
sends NOTIFY to `notify:` targets. Watch `easydns zones transfers ZONE`.
7. Rollback: stop EasyDNS, start BIND (zone files changed via the EasyDNS API stay valid
BIND files, with a higher serial).
## 2. Secondary servers
**Replace a BIND secondary** (primary unchanged, possibly BIND):
1. Configure the zone as `type: secondary` with the same primaries and TSIG key; add the
new host to the primary's `allow-transfer`/`also-notify` if the IP changes.
2. Start EasyDNS; it performs AXFR, then IXFR on NOTIFY or SOA REFRESH. Check
`easydns zones show ZONE` (serial, source, `last_error`) and compare with
`easydiff ZONE SOA @old-secondary @new-secondary`.
3. Swap the service IP or update NS/glue at the registry; decommission BIND after the
old NS TTL has expired.
**Mixed operation** is supported both ways: EasyDNS secondary of a BIND primary, and BIND
secondary of an EasyDNS primary (standard AXFR/IXFR/NOTIFY/TSIG). Useful as a migration
stage: make EasyDNS a secondary first, then promote it (next section).
**Promote an EasyDNS secondary to primary:** copy the snapshot
`<data_dir>/zones/secondary/ZONE.zone` to `<data_dir>/zones/primary/ZONE.zone`, change the zone to `type: primary` with
`file:` pointing to it, reload. The serial continues from the transferred one.
## 3. Recursive resolver (caching resolver for a LAN)
1. `recursion.enabled: true`, `allowed_clients` = BIND `allow-recursion`
(`allow-query-cache` is implied), `resolution.default: recursive`,
`dnssec_validation: true` if BIND had `dnssec-validation auto`.
2. Local/private zones that BIND served as `type master` stay `type: primary`; BIND
`empty-zones-enable` behaviour corresponds to EasyDNS local-only names (RFC 6303),
extend with `recursion.local_only_suffixes`.
3. Compare with the old resolver for a sample of names (e.g. from BIND query logs):
```bash
while read n t; do easydiff "$n" "$t" @old-resolver @127.0.0.1:5300 >/dev/null || echo "DIFF $n $t"; done < sample.txt
```
Differences in address order or TTLs are normal; RCODE/record set differences are not.
4. Load test the new resolver with traffic you own: `easybench @127.0.0.1:5300 -d sample.txt --qps 500`.
5. Switch DHCP/resolv.conf or move the service IP. The cache starts cold (no cache import).
## 4. Forwarder
`forwarders` + `forward only|first` and `type forward` zones map 1:1 (table above).
EasyDNS adds strategies (`failover` ≈ BIND order, `fastest` ≈ BIND RTT selection),
health checks and encrypted upstreams (`tls://ip#name`, `https://ip/dns-query#name`).
## 5. DNSSEC-signed zones
BIND private keys (`K*.private`) cannot be imported. Options:
* **A. Keep signing outside EasyDNS** (BIND as hidden signer, or offline
`dnssec-signzone`): EasyDNS is a secondary of the signer, or serves the pre-signed file
as a `primary` **without** `dnssec:` (RRSIG/NSEC/NSEC3/DNSKEY are loaded from the file).
Re-signing remains the signer's job. No DS change needed.
* **B. Move signing to EasyDNS** (online signing, NSEC) with a DS rollover:
1. `easydns dnssec keygen --zone Z --dir /etc/easydns/data/keys/Z --algorithm ecdsap256`;
2. publish the new DNSKEY in the BIND-signed zone (pre-publish, `dnssec-settime`/`rndc`)
and wait the DNSKEY TTL;
3. add the new DS (`easydns dnssec ds`) at the parent next to the old DS, wait the DS TTL;
4. switch serving to EasyDNS with `dnssec:` enabled (it signs with its key only), and
verify with `easydnssec www.Z`;
5. after the DNSKEY TTL, remove the old DS at the parent.
A zone using NSEC3 in BIND will use NSEC after the switch (NSEC3 signing is not available).
* **C. Unsign and re-sign** (simplest, short insecure window): remove the DS at the
parent, wait the DS TTL, switch to EasyDNS signing, publish the new DS.
## 6. Views / split horizon
Each BIND `view` becomes a `resolution.views` entry (same order; first match wins) and
each zone inside a view gets `views: [name]`; the same zone name may be defined once per
view with different files. Recursion and forwarding settings are global in EasyDNS: if
BIND views differed in `recursion`/`forwarders`, use `recursion.allowed_clients` and
`forward_zones[].clients` to reproduce the difference.
## 7. Dynamic DNS (DHCP, ACME, nsupdate)
* `allow-update { 192.0.2.7; };` → `update_acl: ["192.0.2.7"]` (no key).
* `allow-update { key k; };` → `update_keys: [k]` (+ `update_acl`).
* `update-policy { … };` → `update_policy:` with the rules copied as strings (rule types
`name`, `subdomain`, `wildcard`, `zonesub`, `self`, `selfsub`; Kerberos identities are not
supported).
* Keys: copy `keys.conf` from BIND into `/etc/easydns/keys.d/` unchanged.
`nsupdate`, DHCP servers and ACME clients (certbot `dns-rfc2136`, acme.sh, lego) work
unchanged. A complete translated example is in [primary.md](primary.md#example-translating-a-bind-master-zone).
Every update is in `<data_dir>/audit.log`.
## 8. RPZ (response policy zones)
RPZ is not implemented. Convert the policy zone to a block list: every
`name CNAME .` (NXDOMAIN) or `name CNAME *.` (NODATA) entry becomes a line `name`, and
`*.name` lines become `*.name`. Set `policy.block_action` (`nxdomain`, `refused`, `null`,
`address`). Example conversion:
```bash
easyzone canonical rpz.zone --origin rpz | awk '$4=="CNAME" {n=$1; sub(/\.rpz\.$/,"",n); print n}' > /etc/easydns/blocklists/rpz.txt
```
Feeds (`url:`) are refreshed by `easydns blocklists update` (systemd timer in `deploy/systemd`).
## 9. Final checklist
- [ ] `easyconf check` clean, every zone passes `easyzone check`
- [ ] `easydiff`/AXFR comparison done for every zone
- [ ] transfers and NOTIFY verified with every secondary (`easydns zones transfers`)
- [ ] DNSSEC: `easydnssec` → *secure* for signed zones, DS at the parent matches
- [ ] recursion not open (`easydig @PUBLIC_IP example.org` from outside → REFUSED)
- [ ] API and metrics only on loopback / behind a firewall
- [ ] monitoring (`/metrics`), log shipping, backups of `/etc/easydns` and `/etc/easydns/data`
- [ ] rollback plan: BIND config and files untouched and startable