v0.1.0
This commit is contained in:
commit
fa432bebda
189 files changed
+26219
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
# REST API (`/api/v1`)
|
||||
|
||||
Bearer tokens (`Authorization: Bearer <token>`); roles: `admin` (all) and `read-only` (GET).
|
||||
Default listener: `127.0.0.1:9953`. The server creates a local admin token in
|
||||
`<data_dir>/control.token` (0640, `api.local_token`), used automatically by the `easydns`
|
||||
CLI; define `api.tokens` for remote tools and automation.
|
||||
Errors: `{"error": {"status": 403, "message": "..."}}`. Machine-readable description:
|
||||
`GET /api/v1/openapi.json`.
|
||||
|
||||
| Method | Endpoint | Notes |
|
||||
|---|---|---|
|
||||
| GET | `/api/v1/health`, `/healthz`, `/readyz` | public |
|
||||
| GET | `/api/v1/status` | version, mode, roles, listeners, zone states |
|
||||
| GET | `/api/v1/stats` | counters, latency quantiles, cache hit rate |
|
||||
| GET/POST | `/api/v1/zones` | list (`?page&per_page&name&kind`) / create primary zone (`zone_file` or `ns` + `hostmaster`) |
|
||||
| GET/PUT/DELETE | `/api/v1/zones/{zone}` | details + ETag / replace contents (`zone_file`) / delete API-created zone (409 for config zones) |
|
||||
| GET/POST | `/api/v1/zones/{zone}/records` | list (`?name&type&page&per_page`) / add `{name,type,ttl,data}` |
|
||||
| PUT/DELETE | `/api/v1/zones/{zone}/records/{id}` | replace / delete; `If-Match: "<serial>"` → 412 on conflict |
|
||||
| POST | `/api/v1/zones/{zone}/notify` | send NOTIFY |
|
||||
| POST | `/api/v1/zones/{zone}/sync` | refresh a secondary now |
|
||||
| GET | `/api/v1/zones/{zone}/transfers` | transfer history (in/out) |
|
||||
| GET/DELETE | `/api/v1/cache` | stats / flush (`?domain=`) |
|
||||
| GET/POST | `/api/v1/upstreams` | status / add upstream (persisted, reload) |
|
||||
| GET/PUT | `/api/v1/policies` | ACLs, views, rate limit, policy / update allowlist, block action |
|
||||
| GET/POST | `/api/v1/blocklists` | lists / add a rule |
|
||||
| POST | `/api/v1/config/reload` | hot reload with rollback |
|
||||
| GET | `/api/v1/audit` | audit log tail (`?n=`) |
|
||||
| GET | `/api/v1/query?name=&type=` | resolve through this server |
|
||||
|
||||
All state-changing calls are audited (`<data_dir>/audit.log`, JSON lines). Record IDs are
|
||||
stable hashes of (name, type, data). Changes made via the API persist in the zone files
|
||||
and in `<data_dir>/api-overlay.yaml`.
|
||||
|
||||
```bash
|
||||
T=$(sudo cat /etc/easydns/data/control.token) # or a token from api.tokens
|
||||
curl -H "Authorization: Bearer $T" localhost:9953/api/v1/zones
|
||||
curl -X POST -H "Authorization: Bearer $T" -H 'Content-Type: application/json' \
|
||||
-d '{"name":"www","type":"A","ttl":300,"data":"192.0.2.10"}' \
|
||||
localhost:9953/api/v1/zones/example.com/records
|
||||
```
|
||||
@@ -0,0 +1,86 @@
|
||||
# Architecture
|
||||
|
||||
```
|
||||
crates/
|
||||
dns-core protocol helpers on hickory-proto: client (UDP→TCP, AXFR/IXFR streams, NOTIFY),
|
||||
TSIG (RFC 8945, multi-message), RFC 1982 serials, zone files (+DNSSEC/RFC 3597
|
||||
pre-processor), DNSSEC primitives (sign/verify/DS/NSEC/NSEC3), DoT/DoH client
|
||||
dns-config YAML/JSON schema, ENV/CLI precedence, offline validation with locations
|
||||
dns-authoritative Zone (immutable snapshot + RFC 1034/4592 lookup), journal (IXFR), xfr,
|
||||
store (Primary/Secondary entries, atomic swap), secondary (SOA timers),
|
||||
update (RFC 2136), signing (online DNSSEC)
|
||||
dns-cache bounded LRU answer/RRset cache, namespaces per route, RFC 2308
|
||||
dns-recursive iterative resolver, root hints, validator (DNSSEC chain of trust)
|
||||
dns-forwarder upstream pools, strategies, circuit breaker, health checks
|
||||
dns-policy ACLs, views, rate limiter, block/allow lists, local-only names
|
||||
dns-server listeners (UDP/TCP/DoT/DoH), dispatcher (handler), router (hybrid),
|
||||
encoded-answer cache, query coalescing,
|
||||
runtime snapshot + hot reload, audit log, offline checks
|
||||
dns-api REST API (axum), auth/roles, metrics endpoint
|
||||
dns-metrics low-cardinality counters/histograms, Prometheus text, logging setup
|
||||
dns-cli `easydns`
|
||||
dns-tools ed, eh, ens, etrace, ednssec, eptr, ezone, econf, ebench, ewhois, edoh, edot, ediff
|
||||
```
|
||||
|
||||
## Data flow
|
||||
|
||||
Each listener reads a message and calls `handler::handle(shared, bytes, peer, transport)`,
|
||||
which returns zero, one or many encoded messages (zone transfers). The handler takes an
|
||||
`Arc<Runtime>` snapshot at the start of every query; a reload builds a complete new
|
||||
`Runtime` and swaps the pointer, so in-flight queries finish on the configuration they
|
||||
started with and a failed reload leaves the old one active (rollback).
|
||||
|
||||
Fast path: before parsing, `handler::handle_with` (and, for UDP, `udp_fast_path` inside
|
||||
the receive loop) looks the raw query up in the **encoded-answer cache**
|
||||
(`packet_cache.rs`), keyed by the query bytes and the client profile. A hit is the
|
||||
stored response with the ID, question case and TTLs patched – no parsing, policy,
|
||||
lookup or encoding. Misses take the full path; their responses are stored if cacheable.
|
||||
Zone publication (`ZoneEntry::install`), expiry changes, reloads and cache flushes bump a
|
||||
generation number that invalidates all stored answers. On Linux the UDP loop receives
|
||||
and sends in batches (`recvmmsg`/`sendmmsg`).
|
||||
|
||||
## Zone data
|
||||
|
||||
A `Zone` is immutable and validated on construction (single SOA at the apex, apex NS,
|
||||
no CNAME conflicts, all data in-zone, TTL normalisation per RRset). Changes always build a
|
||||
new `Zone` and publish it with one pointer swap (`ZoneEntry::install`), therefore a query
|
||||
can never observe a half-applied change. IXFR diffs are computed between snapshots and
|
||||
appended to a JSON-lines journal (`<data_dir>/journal/<zone>.jnl`, wire-format records).
|
||||
|
||||
### Why files and not SQLite?
|
||||
|
||||
The spec asks for a durable backend for zones, transfer journals and admin data and to
|
||||
justify the choice. EasyDNS uses plain files because:
|
||||
* zones stay in BIND format, editable and diffable by operators (spec: "identycznie do bind");
|
||||
* the only mutable data is append-only (journal, audit) or replaced atomically
|
||||
(`write tmp → fsync → rename → fsync dir`), which needs no transactions;
|
||||
* no extra native dependency, trivial backup (`tar` of `/etc/easydns` + `/etc/easydns/data`).
|
||||
Schema "migrations" are version-tolerant readers: unknown journal lines truncate the
|
||||
journal (IXFR then falls back to AXFR); snapshots are plain zone files.
|
||||
|
||||
| Path (`data_dir`) | Content |
|
||||
|---|---|
|
||||
| `zones/secondary/<zone>.zone` + `.meta.json` | last valid secondary copy + last successful refresh |
|
||||
| `journal/<zone>.jnl` | IXFR differences |
|
||||
| `signed/<zone>.zone` | last signed version of DNSSEC zones (keeps signatures stable across restarts) |
|
||||
| `zones/` | zones created via the API |
|
||||
| `api-overlay.yaml` | API changes (zones, upstreams, allowlist, block rules) merged on load |
|
||||
| `blocklists/` | downloaded/API block lists |
|
||||
| `audit.log` | JSON lines of administrative actions |
|
||||
|
||||
## Hybrid decision order
|
||||
|
||||
1. local authoritative zone (most specific, visible in the client's view) → AA answer;
|
||||
2. client not allowed to recurse → REFUSED;
|
||||
3. local-only names (RFC 6761/6303, configurable) → NXDOMAIN, never sent out;
|
||||
4. allow/block policy;
|
||||
5. conditional forwarding (longest suffix, optional client ACL);
|
||||
6. default resolution: `recursive`, `forward`, `forwardthenrecursive` or `refuse`.
|
||||
|
||||
Each route has its own cache namespace; authoritative data is never cached.
|
||||
|
||||
## Extension points
|
||||
|
||||
* Transports: implement a listener that feeds `handler::handle` (DoQ/DoH3 planned).
|
||||
* Zone backends: `ZoneEntry` owns loading/persisting; a database backend would replace
|
||||
`load_primary_file`/`modify` while keeping snapshot publication unchanged.
|
||||
@@ -0,0 +1,117 @@
|
||||
# CLI: `easydns` and EasyDNS Tools
|
||||
|
||||
## easydns
|
||||
|
||||
```
|
||||
easydns run [--listen ADDR]... [--log-level L] [--data-dir D]
|
||||
easydns check-config | config validate | config show
|
||||
easydns status | version | query NAME [TYPE] | reload
|
||||
easydns zone create ZONE [--ns NAME[=IP]]... [--ip IP]... [--email E] [--allow-transfer IP]...
|
||||
[--notify IP]... [--allow-update IP]... [--ttl S] [--dry-run] [--force] [--reload]
|
||||
easydns zones list|show|sync|notify|transfers|records ZONE (`zone` is an alias of `zones`)
|
||||
easydns cache clear [--domain D] | cache stats
|
||||
easydns upstreams list
|
||||
easydns blocklists update easydns root-hints update
|
||||
easydns dnssec keygen --zone Z --dir D [--role csk|ksk|zsk] [--algorithm ed25519]
|
||||
easydns dnssec ds --zone Z --dir D
|
||||
easydns hash-token TOKEN easydns tools
|
||||
easydns completions bash|zsh|fish|elvish|powershell easydns man
|
||||
```
|
||||
Global: `-c/--config` (default `/etc/easydns/config.yaml`), `--api URL`, `--token`
|
||||
(`EASYDNS_API_TOKEN`), `--json`.
|
||||
Exit codes: 0 ok, 1 operation failed, 2 invalid usage/configuration, 3 API unreachable.
|
||||
|
||||
**No key needed locally.** Commands that talk to the running server (`status`, `reload`,
|
||||
`zones …`, `cache …`, `query`) use the API on `127.0.0.1:9953`. Without `--token` the CLI
|
||||
reads the server's local control token from `<data_dir>/control.token` (created by the
|
||||
server, mode 0640, readable by root and the `easydns` group). So after installation
|
||||
`sudo easydns status` simply works; add your admin user to the `easydns` group to drop
|
||||
`sudo`. `--token` is only needed for remote servers or when `api.local_token: false`.
|
||||
|
||||
### Creating a zone
|
||||
|
||||
`easydns zone create` writes a minimal, valid primary zone – SOA, NS, glue for in-zone
|
||||
name servers and optional apex addresses – into `<data_dir>/zones/<zone>.zone`
|
||||
(`/etc/easydns/data/zones/`) and its definition into `/etc/easydns/zones.d/<zone>.yaml`.
|
||||
The zone is parsed and validated before anything is written; existing files are never
|
||||
overwritten without `--force`.
|
||||
|
||||
```bash
|
||||
# name servers inside the zone need an address (glue)
|
||||
easydns zone create example.com --ns ns1.example.com=192.0.2.10 --ns ns2.example.net --ip 192.0.2.80
|
||||
# external name servers only, mailbox, secondary allowed to transfer + NOTIFY, reload at once
|
||||
easydns zone create example.org --ns ns1.example.net --ns ns2.example.net \
|
||||
--email dns-admin@example.net --allow-transfer 198.51.100.20 --notify 198.51.100.20 --reload
|
||||
# preview only
|
||||
easydns zone create example.net --ns ns.example.org --dry-run
|
||||
```
|
||||
|
||||
Result for the first command:
|
||||
```
|
||||
; example.com. – created by `easydns zone create`
|
||||
$ORIGIN example.com.
|
||||
$TTL 3600
|
||||
@ IN SOA ns1.example.com. hostmaster.example.com. (
|
||||
2026112201 ; serial
|
||||
3600 ; refresh
|
||||
900 ; retry
|
||||
1209600 ; expire
|
||||
300 ) ; negative TTL
|
||||
@ IN NS ns1.example.com.
|
||||
@ IN NS ns2.example.net.
|
||||
ns1 IN A 192.0.2.10
|
||||
@ IN A 192.0.2.80
|
||||
```
|
||||
```yaml
|
||||
# /etc/easydns/zones.d/example.com.yaml
|
||||
- name: example.com
|
||||
type: primary
|
||||
file: zones/example.com.zone
|
||||
```
|
||||
|
||||
| Option | Meaning (default) |
|
||||
|---|---|
|
||||
| `--ns NAME[=IP]` | name server, repeatable (`ns1.<zone>`; in-zone names need `=IP` unless `--ip` is given) |
|
||||
| `--ip IP` | `@ A`/`@ AAAA`, repeatable; also glue for a default `ns1` without its own address |
|
||||
| `--email` | SOA mailbox (`hostmaster@<zone>`) |
|
||||
| `--ttl` | `$TTL` (3600) |
|
||||
| `--allow-transfer IP` | `transfer_acl` – secondaries allowed to transfer, **no key needed** |
|
||||
| `--notify IP[:PORT]` | secondaries to NOTIFY |
|
||||
| `--allow-update IP` | RFC 2136 updates from these addresses without a key |
|
||||
| `--no-config` | write only the zone file and print the definition |
|
||||
| `--dry-run`, `--force`, `--reload` | preview / overwrite / reload the server afterwards |
|
||||
|
||||
Serial: `YYYYMMDD01`. Files are created mode 0640 and, when run as root, owned by the
|
||||
owner of the data directory (the `easydns` user), so the server can later write DDNS and
|
||||
API changes. Then add records to the file and run `easydns reload` (or use the REST API).
|
||||
|
||||
## Tools
|
||||
|
||||
Every tool has a short and a long binary name, `--help`, `--version`, `--json` where the
|
||||
output is structured. Exit codes: 0 success (a DNS answer, also NXDOMAIN for `ed`),
|
||||
1 usage error / negative result (eh, eptr) / differences (ediff), 9 no reply, 10 internal error.
|
||||
|
||||
| Tool | Replaces | Examples |
|
||||
|---|---|---|
|
||||
| `ed` / `easydig` | dig | `ed @1.1.1.1 example.com MX +short`, `ed -x 8.8.8.8`, `ed example.com +dnssec +tcp`, `ed example.com --json`, `--yaml`, `--watch 5s`, `--compare 1.1.1.1,8.8.8.8`, `--benchmark 1000`, `-y hmac-sha256:key:SECRET example.com AXFR` |
|
||||
| `eh` / `easyhost` | host | `eh example.com`, `eh -t MX example.com`, `eh 8.8.8.8`, `eh --all example.com`, `eh --json example.com` |
|
||||
| `ens` / `easynslookup` | nslookup | `ens example.com 8.8.8.8`, `ens -type=MX example.com`, `ens --interactive` (`server X`, `set type=AAAA`, `exit`) |
|
||||
| `etrace` / `easytrace` | dig +trace | `etrace example.com --dnssec --json` |
|
||||
| `ednssec` / `easydnssec` | delv | `ednssec example.com A -v` (secure/insecure/bogus with reason; exit 2 = bogus) |
|
||||
| `eptr` / `easyptr` | dig -x | `eptr 192.0.2.1 2001:db8::1 --verify` (forward-confirmed) |
|
||||
| `ezone` / `easyzone` | named-checkzone | `ezone check zones/example.com.zone --origin example.com`, `ezone validate --all -c config.yaml`, `ezone canonical ...` |
|
||||
| `econf` / `easyconf` | named-checkconf | `econf check config.yaml`, `econf print config.yaml` |
|
||||
| `ebench` / `easybench` | dnsperf | `ebench @127.0.0.1 --qps 1000 --duration 30s -c 50 -d queries.txt` (high load needs `--i-own-this-server`) |
|
||||
| `ediff` / `easydiff` | – | `ediff example.com MX @1.1.1.1 @8.8.8.8 --json` (order-insensitive, TTL shown not compared) |
|
||||
| `edoh` / `easydoh` | – | `edoh https://1.1.1.1/dns-query example.com --method get`, `--http2` (reports whether h2 was negotiated) |
|
||||
| `edot` / `easydot` | – | `edot 1.1.1.1 example.com --tls-name cloudflare-dns.com` |
|
||||
| `ewhois` / `easywhois` | whois | `ewhois example.com` (RDAP via IANA bootstrap), `ewhois --whois 192.0.2.1` |
|
||||
|
||||
Output colours are used only on a TTY (`--no-color`, `NO_COLOR`). The default server is the
|
||||
first `nameserver` in `/etc/resolv.conf`.
|
||||
|
||||
`ed` and `eh` can clash with existing commands (`ed` is the classic editor). The installer
|
||||
links short names only when they are free; long names are always installed.
|
||||
|
||||
Compatibility is tested by *meaning*: `scripts/e2e.sh` compares `ed … +short` with `dig … +short`
|
||||
after sorting (RRset order and TTLs may differ).
|
||||
@@ -0,0 +1,208 @@
|
||||
# Configuration
|
||||
|
||||
`config.yaml` (JSON is accepted too). Unknown keys are rejected with file/line information.
|
||||
Precedence: **CLI > ENV > file > defaults**, then changes made through the API
|
||||
(`<data_dir>/api-overlay.yaml`) are merged.
|
||||
|
||||
Validate offline: `easydns check-config -c config.yaml` or `econf check config.yaml`
|
||||
(also loads every primary zone file). Exit code 2 on errors.
|
||||
|
||||
## Default installation layout
|
||||
|
||||
| Path | Contents | Owner / mode |
|
||||
|---|---|---|
|
||||
| `/etc/easydns/config.yaml` | main configuration ([config/config.yaml](../config/config.yaml)) | root:easydns 0640 |
|
||||
| `/etc/easydns/zones.d/*.yaml` | zone definitions, one file per zone (`easydns zone create` writes here) | root:easydns 0750 |
|
||||
| `/etc/easydns/keys.d/*.conf` | TSIG keys – BIND `key "…" { … };` files copied unchanged | root:easydns 0640 |
|
||||
| `/etc/easydns/data/` | `server.data_dir`: everything the server writes | easydns:easydns 0750 |
|
||||
| `/etc/easydns/data/zones/` | zone files of primary zones (`file: zones/example.com.zone`) | easydns |
|
||||
| `/etc/easydns/data/zones/secondary/` | copies of secondary zones (+ `.meta.json`) | easydns |
|
||||
| `/etc/easydns/data/journal/` | IXFR journals | easydns |
|
||||
| `/etc/easydns/data/control.token` | local admin token for the CLI | easydns 0640 |
|
||||
| `/etc/easydns/data/audit.log`, `api-overlay.yaml`, `signed/` | audit trail, API changes, signed zones | easydns |
|
||||
|
||||
The default configuration runs a **hybrid** node: authoritative for the zones in
|
||||
`zones.d/`, recursive resolver for `acls.lan` (`192.168.0.0/16`, `10.0.0.0/8`,
|
||||
`127.0.0.1/32`; add `172.16.0.0/12` if you use it), listening on `0.0.0.0:53` and
|
||||
`[::1]:53`.
|
||||
|
||||
## Zone file paths
|
||||
|
||||
A relative zone `file:` is relative to `server.data_dir`: `file: zones/example.com.zone`
|
||||
is `/etc/easydns/data/zones/example.com.zone`. Absolute paths are used as they are.
|
||||
(Older configurations whose relative paths point next to the config file keep working:
|
||||
if the file is not found under `data_dir` but exists relative to the configuration
|
||||
directory, that one is used.)
|
||||
|
||||
## Include files
|
||||
|
||||
Zone definitions (and keys, ACLs, forward zones) can be split into separate files, like
|
||||
BIND's `include "named.conf.zones";`:
|
||||
|
||||
```yaml
|
||||
# /etc/easydns/config.yaml
|
||||
include:
|
||||
- "zones.d/*.yaml" # glob in the file name; sorted; empty directory is fine
|
||||
- "keys.yaml" # literal path; must exist
|
||||
server: { ... }
|
||||
```
|
||||
|
||||
An included file is either a **list of zones**:
|
||||
```yaml
|
||||
- { name: example.org, type: secondary, primaries: ["192.0.2.53:53"] }
|
||||
- { name: example.net, type: secondary, primaries: ["192.0.2.53:53"] }
|
||||
```
|
||||
or a **mapping** with any of `zones`, `keys`, `acls`, `forward_zones` and a nested
|
||||
`include` (relative to that file):
|
||||
```yaml
|
||||
keys: [ { name: example-net-xfr, secret: "env:DNS_TSIG_EXAMPLE_NET" } ]
|
||||
acls: { example-net-primaries: ["198.51.100.10/32"] }
|
||||
zones: [ { name: example.net, type: secondary, primaries: ["198.51.100.10:53"], transfer: { tsig_key: example-net-xfr } } ]
|
||||
```
|
||||
|
||||
A file whose first statement is a BIND **`key`** statement is read as a BIND key file, so
|
||||
`keys.conf` from a BIND server can be included unchanged:
|
||||
```
|
||||
key "ddns.example.com" {
|
||||
algorithm hmac-sha512;
|
||||
secret "base64-secret";
|
||||
};
|
||||
```
|
||||
Only `key { algorithm; secret; };` is accepted there (comments `#`, `//`, `/* */` allowed);
|
||||
any other statement is an error with its line number. Keep such files `0640 root:easydns`
|
||||
– `check-config` warns when they are world-readable.
|
||||
|
||||
Rules: include patterns are relative to the including file; zone `file:` paths are
|
||||
relative to `data_dir` (see above) and `file:` secret references to the **main**
|
||||
configuration file's directory;
|
||||
hidden files and `*~` backups are skipped; recursive/duplicate includes and redefined ACLs
|
||||
are errors; duplicate zones are reported with the file they come from; nesting depth ≤ 8.
|
||||
Includes are re-read on every reload, so adding a zone = drop a file into `zones.d/` and
|
||||
run `easydns reload`. Zone files themselves support BIND `$INCLUDE`.
|
||||
|
||||
## Environment overrides
|
||||
|
||||
| Variable | Effect |
|
||||
|---|---|
|
||||
| `EASYDNS_LISTEN` | comma-separated listen addresses |
|
||||
| `EASYDNS_LOG_LEVEL` | log level / filter |
|
||||
| `EASYDNS_DATA_DIR` | data directory |
|
||||
| `EASYDNS_API_LISTEN` | API listen address |
|
||||
| `EASYDNS_LOG` | full `tracing` filter (e.g. `info,query=info`) |
|
||||
|
||||
CLI: `easydns run --listen 127.0.0.1:5353 --log-level debug --data-dir /tmp/x`.
|
||||
|
||||
## Secrets
|
||||
|
||||
TSIG secrets and API tokens are **references**: `env:VAR`, `file:/path` or (discouraged,
|
||||
warned) `base64:...`; API tokens may also be `sha256:<hex>` (`easydns hash-token`).
|
||||
TSIG keys can also come from BIND key files in `keys.d/` (see above).
|
||||
Secrets are never logged (`TsigKey` redacts itself in debug output).
|
||||
|
||||
TSIG keys are **optional** everywhere: zone transfers, NOTIFY and dynamic updates can be
|
||||
authorised by IP address alone (see [zone-transfer-variants.md](zone-transfer-variants.md)
|
||||
and [primary.md](primary.md#dynamic-updates-rfc-2136)).
|
||||
|
||||
The local API token (`api.local_token`, default on) is created by the server in
|
||||
`<data_dir>/control.token` with mode 0640; the `easydns` CLI reads it automatically, so
|
||||
`easydns status`, `easydns reload` etc. work right after installation for root and members
|
||||
of the `easydns` group, without generating or passing a key. Set `local_token: false` to
|
||||
require explicit tokens only.
|
||||
|
||||
## Sections (defaults in brackets)
|
||||
|
||||
```yaml
|
||||
server:
|
||||
mode: hybrid # primary|master, secondary|slave, recursive|resolver, forwarder, hybrid|mixed, cache-only
|
||||
listen: ["0.0.0.0:53", "[::1]:53"] # [::] addresses are IPv6-only, so they can be listed next to 0.0.0.0
|
||||
udp: true
|
||||
tcp: true
|
||||
data_dir: data # relative to the config file → /etc/easydns/data
|
||||
max_tcp_connections: 1024
|
||||
tcp_idle_timeout: 10s
|
||||
max_udp_payload: 1232
|
||||
max_inflight: 10000 # server-wide limit of UDP queries being processed at once
|
||||
udp_sockets: 0 # UDP sockets per address (SO_REUSEPORT); 0 = one per CPU, max 16
|
||||
identity: null # answers id.server/version.bind (CH TXT) only when set
|
||||
logging: { level: info, format: text|json, query_log: false, anonymize_clients: true }
|
||||
keys: [ { name, algorithm: hmac-sha256, secret: "env:..." } ]
|
||||
acls: { name: ["10.0.0.0/8", "acl:other", "any", "none"] }
|
||||
recursion:
|
||||
enabled: false
|
||||
root_hints: null # built-in IANA hints when unset
|
||||
allowed_clients: ["192.168.0.0/16", "10.0.0.0/8", "127.0.0.1/32", "::1/128"]
|
||||
qname_minimization: true
|
||||
dnssec_validation: false
|
||||
trust_anchors: null # DS/DNSKEY file; built-in root KSKs when unset
|
||||
max_depth: 30
|
||||
max_queries: 100
|
||||
max_cname_chain: 8
|
||||
query_timeout: 1500ms
|
||||
total_timeout: 10s
|
||||
local_only_suffixes: []
|
||||
use_ipv6_transport: false
|
||||
zones: # see primary.md / secondary.md
|
||||
- name: example.com
|
||||
type: primary
|
||||
file: zones/example.com.zone # relative to data_dir
|
||||
transfer_acl: [] # IPs allowed to AXFR/IXFR
|
||||
transfer_tsig_key: null # optional key for transfers
|
||||
notify: [] # secondaries to NOTIFY
|
||||
notify_tsig_key: null
|
||||
update_acl: [] # alias allow_update; alone = updates by IP without a key
|
||||
update_keys: [] # keys that may change the whole zone
|
||||
update_policy: [] # BIND-style rules: "grant <key> name|subdomain|wildcard|zonesub|self|selfsub [name] [types]"
|
||||
serial_strategy: increment
|
||||
journal_size: 100
|
||||
views: []
|
||||
dnssec: null
|
||||
forward_zones: [ { domain, upstreams, strategy, clients, fallback_recursion } ]
|
||||
upstreams: { strategy: failover, servers: [], timeout: 2s, health_check_interval: 30s, tls_ca_file: null }
|
||||
resolution: { default: refuse|recursive|forward|forwardthenrecursive, views: [ { name, clients } ] }
|
||||
cache: { enabled: true, max_entries: 100000, min_ttl: 0, max_ttl: 86400, max_negative_ttl: 3600, serve_stale: false, stale_ttl: 30,
|
||||
answer_entries: 20000, # encoded-answer (packet) cache; 0 = off
|
||||
answer_max_age: 30s, # max reuse of local-zone answers (zone changes invalidate at once)
|
||||
prefetch: true } # refresh popular resolver entries before they expire
|
||||
policy: { blocklists: [ { name, file|url, category, enabled } ], allowlist: [], block_action: nxdomain|refused|null|address,
|
||||
block_address_v4: 0.0.0.0, block_address_v6: "::", block_ttl: 60, exempt_clients: [], log_blocked: true }
|
||||
rate_limit: { enabled: true, per_client_qps: 200, burst: 400, global_qps: 0, slip: 2, exempt_clients: [loopback] } # global_qps 0 = no server-wide cap
|
||||
tls: { cert_file, key_file, dot_listen: [], doh_listen: [], doh_plaintext_behind_proxy: false } # certificate files re-read within 60 s of a change
|
||||
api: { enabled: true, listen: 127.0.0.1:9953, auth_required: true, local_token: true, tokens: [], allowed_clients: [loopback], requests_per_minute: 600 }
|
||||
metrics: { enabled: true, listen: 127.0.0.1:9090 }
|
||||
```
|
||||
|
||||
Durations accept `500ms`, `2s`, `5m`, `1h`, `1d` or plain seconds.
|
||||
|
||||
### Encoded-answer cache (`cache.answer_entries`)
|
||||
|
||||
Complete responses are kept in encoded form and reused for identical queries: the copy
|
||||
gets the client's message ID and question spelling, and TTLs of resolved data are
|
||||
counted down. A hit costs no parsing, no policy evaluation and no zone lookup, and UDP
|
||||
hits are answered directly in the receive loop (batched with `sendmmsg` on Linux).
|
||||
|
||||
* The key includes everything that can change the answer: the query (flags, EDNS, DO bit,
|
||||
UDP size) and the client's view, recursion permission, block-list exemption,
|
||||
client-specific forward rules and transport (UDP/TCP). TSIG-signed queries are never
|
||||
cached; only NOERROR/NXDOMAIN answers are stored.
|
||||
* Zone changes (file reload, API, DDNS, re-signing, secondary transfer or expiry), a
|
||||
configuration reload and `easydns cache clear` invalidate it immediately.
|
||||
* With `logging.query_log: true` the cache is bypassed, so every query is logged.
|
||||
* Memory: about 0.3–1 KiB per entry (20 000 entries ≈ 6–20 MB at most).
|
||||
* Metrics: `dns_answer_cache_hits_total`, `…_misses_total`, `…_inserts_total`, `dns_answer_cache_entries`.
|
||||
|
||||
## Upstream syntax
|
||||
|
||||
`1.1.1.1`, `1.1.1.1:53`, `[2606:4700::1111]:53`, `tcp://1.1.1.1`,
|
||||
`tls://1.1.1.1#cloudflare-dns.com`, `https://1.1.1.1/dns-query#cloudflare-dns.com`
|
||||
(`#name` is the TLS certificate name and is mandatory for TLS upstreams).
|
||||
DoT upstreams use a pool of persistent connections; DoH upstreams use one persistent,
|
||||
multiplexed HTTP/2 connection (HTTP/1.1 if the server lacks h2). Certificates are checked
|
||||
against the built-in Mozilla roots plus `upstreams.tls_ca_file`. See
|
||||
[secure-dns.md](secure-dns.md).
|
||||
|
||||
## Hot reload
|
||||
|
||||
`kill -HUP <pid>`, `systemctl reload easydns`, `easydns reload` or `POST /api/v1/config/reload`.
|
||||
The new configuration is validated and built completely before it is switched in; on any
|
||||
error the running configuration stays active. Settings that need a restart are reported
|
||||
(`restart_required`).
|
||||
@@ -0,0 +1,88 @@
|
||||
# Deployment
|
||||
|
||||
## After installing the .deb package
|
||||
|
||||
```bash
|
||||
sudo apt install ./dist/easydns_0.1.0-1_amd64.deb
|
||||
sudo easydns zone create example.com --ns ns1.example.com=192.0.2.10 --ip 192.0.2.80
|
||||
sudo systemctl enable --now easydns
|
||||
sudo easydns status # no key to generate or pass
|
||||
easydig @127.0.0.1 example.com SOA +short
|
||||
```
|
||||
The package installs the default hybrid configuration (`/etc/easydns/config.yaml`:
|
||||
`0.0.0.0:53` + `[::1]:53`, recursion for `192.168.0.0/16`, `10.0.0.0/8`, `127.0.0.1`),
|
||||
creates `/etc/easydns/{zones.d,keys.d,data/zones}` and the `easydns` user. Layout:
|
||||
[configuration.md](configuration.md#default-installation-layout). On hosts where
|
||||
systemd-resolved occupies `127.0.0.53:53` there is no conflict (different address); if
|
||||
another DNS server listens on `0.0.0.0:53`, stop it or change `server.listen`.
|
||||
|
||||
## Upgrading the package (keeping your configuration)
|
||||
|
||||
```bash
|
||||
sudo tar czf /root/easydns-backup-$(date +%F).tgz /etc/easydns # config, zones, keys, data
|
||||
scripts/build-deb.sh # → dist/easydns_<ver>_<arch>.deb
|
||||
sudo apt install -o Dpkg::Options::=--force-confold ./dist/easydns_*_amd64.deb
|
||||
```
|
||||
* `/etc/easydns/config.yaml` and `root.hints` are conffiles: `--force-confold` keeps your
|
||||
version without asking; the new default is saved next to it as `config.yaml.dpkg-dist`
|
||||
(without the option dpkg asks – answer **N** to keep yours).
|
||||
* Files in `zones.d/`, `keys.d/` and `data/` are never touched by the package.
|
||||
* A running server is restarted only if the new version accepts the configuration
|
||||
(`easydns check-config` as the `easydns` user); otherwise the old version keeps
|
||||
running and the reason is in `/tmp/easydns-upgrade-check.log`.
|
||||
* Secondary zone copies from older versions (`data/secondary/`) are moved automatically
|
||||
to `data/zones/secondary/` on the first start, so zones are served immediately.
|
||||
* After the upgrade: `sudo easydns check-config`, `journalctl -u easydns -n 50`, and
|
||||
query a few zones (`easydig @127.0.0.1 example.com SOA +short`).
|
||||
|
||||
## systemd (manual installation)
|
||||
|
||||
```bash
|
||||
sudo useradd --system --home /etc/easydns/data --shell /usr/sbin/nologin easydns
|
||||
sudo deploy/install.sh /usr # binaries (+ short tool names when free)
|
||||
sudo install -d -o root -g easydns -m 0750 /etc/easydns /etc/easydns/zones.d /etc/easydns/keys.d
|
||||
sudo install -d -o easydns -g easydns -m 0750 /etc/easydns/data /etc/easydns/data/zones
|
||||
sudo install -m 0640 -g easydns config/config.yaml /etc/easydns/config.yaml # or config/primary.yaml, secondary.yaml, …
|
||||
sudo cp deploy/systemd/easydns.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload && sudo systemctl enable --now easydns
|
||||
sudo systemctl reload easydns # hot reload (SIGHUP)
|
||||
```
|
||||
Secrets for `env:` references (optional) go to `/etc/easydns/easydns.env` (mode 0640).
|
||||
Block list updates: `deploy/systemd/easydns-blocklists.{service,timer}`.
|
||||
|
||||
## Docker
|
||||
|
||||
`docker compose up -d` builds `deploy/docker/Dockerfile` (multi-stage, Debian slim,
|
||||
non-root, `CAP_NET_BIND_SERVICE` only, read-only root). Mount `./config` to `/etc/easydns`
|
||||
and keep `/etc/easydns/data` on a volume. Multi-arch:
|
||||
`docker buildx build --platform linux/amd64,linux/arm64 -f deploy/docker/Dockerfile .`
|
||||
|
||||
## Ports
|
||||
|
||||
53/udp+tcp (DNS), 853/tcp (DoT, optional), DoH port as configured (e.g. 443), 9953 API (loopback) and
|
||||
9090 metrics on loopback by default. Do not expose the API, metrics or recursion to the
|
||||
Internet without explicit ACLs and TLS (reverse proxy).
|
||||
|
||||
## Packages and archives
|
||||
|
||||
`scripts/build-deb.sh [--arch amd64,arm64] [--debian bookworm] [--revision N] [--test]` builds
|
||||
`dist/easydns_<version>-<rev>_<arch>.deb` entirely inside Docker (`deploy/docker/Dockerfile.deb`,
|
||||
control/maintainer scripts in `deploy/packaging/debian/`); `--test` installs the package in a
|
||||
clean container and runs a smoke query. The package installs a `easydns` system user, the
|
||||
systemd units, `/etc/easydns/config.yaml` (conffile), man page, completions, and creates short
|
||||
tool names only where they are free.
|
||||
|
||||
|
||||
`deploy/release.sh` builds x86_64/aarch64 archives with SHA256SUMS; `deploy/packaging/nfpm.yaml`
|
||||
builds .deb/.rpm (`nfpm pkg -p deb|rpm`). `cargo install --path crates/dns-cli` and
|
||||
`--path crates/dns-tools` work too. `easydns --version` prints version and commit.
|
||||
|
||||
## Backup / restore / upgrade
|
||||
|
||||
* Back up `/etc/easydns` – one directory holds everything: config, `zones.d/`,
|
||||
`keys.d/` (secrets!) and `data/` (zone files, snapshots, journals, signed zones, audit log).
|
||||
* Purging the package never deletes `/etc/easydns` (your zones and keys).
|
||||
* Restore: put the directories back and start; secondaries re-validate EXPIRE on startup.
|
||||
* Upgrades are in place; formats are versionless/forward-tolerant (zone files, JSON
|
||||
lines). Rollback = previous binary + the same directories. A corrupt journal is
|
||||
truncated automatically (IXFR then falls back to AXFR).
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
# DNSSEC
|
||||
|
||||
## Step by step: signing your domain and registering it with the registrar
|
||||
|
||||
Example: zone `example.com` served by EasyDNS as primary (`ns1.example.com`) with one
|
||||
secondary (`ns2.example.net`). The domain is registered through a registrar (the
|
||||
"operator" whose panel you use to manage name servers); the registry of the TLD
|
||||
(e.g. `.com`, `.pl`) accepts the DS record only from the registrar.
|
||||
|
||||
### 0. Before you start
|
||||
|
||||
- [ ] Every authoritative server of the domain gets the zone from this EasyDNS primary
|
||||
(EasyDNS or BIND secondaries transfer the *signed* zone unchanged). A secondary that
|
||||
is not fed from this primary would serve unsigned data – fix that first.
|
||||
- [ ] The registrar supports DNSSEC (look for "DNSSEC" / "DS records" in the domain panel,
|
||||
or ask support). Most panels accept algorithm **13 (ECDSA P-256)**; algorithm 15
|
||||
(Ed25519) is accepted by fewer registrars and TLDs – use 13 unless you know 15 works.
|
||||
- [ ] The server clock is synchronised (NTP): signatures carry validity dates.
|
||||
- [ ] You can wait: the whole procedure takes about a day because of TTLs.
|
||||
|
||||
### 1. Generate the key
|
||||
|
||||
```bash
|
||||
sudo easydns dnssec keygen --zone example.com --dir /etc/easydns/data/keys/example.com --algorithm ecdsap256
|
||||
# created /etc/easydns/data/keys/example.com/example.com.56013.csk.key (key tag 56013, csk)
|
||||
# DS for the parent zone:
|
||||
# example.com. 3600 IN DS 56013 13 2 7170CB4FD554C23F491F62C8DE2D518BFD24EB1766A05D70C5AB2FE5D1A7E6FE
|
||||
```
|
||||
One combined signing key (CSK) is created: simple and fully sufficient for most domains.
|
||||
The directory is created with mode 0700 and the file with 0600, owned by the `easydns`
|
||||
user. Keep the keys under `/etc/easydns/data/` – the systemd unit allows the service to
|
||||
write only there (needed when `auto_generate` creates keys itself).
|
||||
|
||||
**Back up the key directory** (encrypted). Losing the key of a signed domain means an
|
||||
emergency rollover; a leaked key lets others sign data for your domain.
|
||||
|
||||
### 2. Enable signing for the zone
|
||||
|
||||
`/etc/easydns/zones.d/example.com.yaml`:
|
||||
```yaml
|
||||
- name: example.com
|
||||
type: primary
|
||||
file: zones/example.com.zone # stays unsigned – keep editing it as before
|
||||
transfer_acl: ["198.51.100.20"]
|
||||
notify: ["198.51.100.20:53"]
|
||||
dnssec:
|
||||
keys_dir: /etc/easydns/data/keys/example.com
|
||||
algorithm: ecdsap256
|
||||
```
|
||||
```bash
|
||||
sudo easydns check-config && sudo easydns reload
|
||||
```
|
||||
EasyDNS adds DNSKEY, NSEC and RRSIG records, bumps the serial, stores the signed copy in
|
||||
`/etc/easydns/data/signed/` and sends NOTIFY, so the secondaries transfer the signed zone.
|
||||
(If the key directory is empty, `auto_generate: true` creates the key at this point –
|
||||
step 1 is then optional; get the DS with step 4.)
|
||||
|
||||
### 3. Check the signed zone on every name server
|
||||
|
||||
```bash
|
||||
easydig @ns1.example.com example.com DNSKEY +dnssec +short # 257 3 13 … + RRSIG DNSKEY …
|
||||
easydig @ns1.example.com www.example.com A +dnssec # answer + RRSIG
|
||||
easydig @ns1.example.com nothing.example.com A +dnssec # NXDOMAIN + NSEC + RRSIG
|
||||
ediff example.com DNSKEY @ns1.example.com @ns2.example.net # same keys everywhere
|
||||
ediff example.com SOA @ns1.example.com @ns2.example.net # same serial everywhere
|
||||
```
|
||||
Do not go on until **all** name servers return the DNSKEY and signatures. Until the DS
|
||||
exists at the parent, resolvers treat the domain as unsigned (*insecure*), so nothing
|
||||
can break yet.
|
||||
|
||||
### 4. Get the DS (or DNSKEY) for the registrar
|
||||
|
||||
```bash
|
||||
sudo easydns dnssec ds --zone example.com --dir /etc/easydns/data/keys/example.com
|
||||
# example.com. 3600 IN DNSKEY 257 3 13 ZsxUqxgMi2LA…EMTVLw==
|
||||
# example.com. 3600 IN DS 56013 13 2 7170CB4FD554C23F491F62C8DE2D518BFD24EB1766A05D70C5AB2FE5D1A7E6FE
|
||||
```
|
||||
|
||||
| Registrar form field | Value from the DS line |
|
||||
|---|---|
|
||||
| Key tag | `56013` |
|
||||
| Algorithm | `13` (ECDSAP256SHA256) – `15` for Ed25519, `14` for ECDSA P-384 |
|
||||
| Digest type | `2` (SHA-256) |
|
||||
| Digest | `7170CB4F…E6FE` (64 hex characters, without spaces) |
|
||||
|
||||
Some panels ask for the **DNSKEY** instead: flags `257`, protocol `3`, algorithm `13`,
|
||||
public key = the base64 string from the DNSKEY line.
|
||||
|
||||
### 5. Submit it at the registrar
|
||||
|
||||
In the registrar's panel: domain → DNSSEC (sometimes "Security" or "DS records") → add a
|
||||
DS record with the four values above → save. Some registrars do it through a support
|
||||
ticket – send them the DS line. The registry usually publishes it within minutes to a few
|
||||
hours.
|
||||
|
||||
EasyDNS does not publish CDS/CDNSKEY records, so automatic DS updates by the registry
|
||||
(RFC 8078) are not available – DS changes always go through the registrar.
|
||||
|
||||
### 6. Verify the chain of trust from the outside
|
||||
|
||||
```bash
|
||||
easydig @1.1.1.1 example.com DS +short # the DS you submitted (via a public resolver)
|
||||
ednssec example.com SOA # walks root → TLD → example.com: should end "secure"
|
||||
easydig @1.1.1.1 www.example.com A +dnssec # flags must contain "ad"
|
||||
easydig @9.9.9.9 www.example.com A # validating resolver: NOERROR, not SERVFAIL
|
||||
```
|
||||
A graphical check: https://dnsviz.net/ (enter the domain). If validating resolvers
|
||||
return **SERVFAIL**, the DS does not match the published key: compare
|
||||
`easydns dnssec ds …` with `easydig DS example.com +short`, fix the DS at the registrar,
|
||||
and in an emergency remove the DS there (the domain then becomes *insecure*, i.e. works
|
||||
unsigned).
|
||||
|
||||
### 7. Running a signed zone
|
||||
|
||||
* Edit the zone file, raise the serial and `easydns reload` as before; API and RFC 2136
|
||||
changes work too – every change is re-signed automatically.
|
||||
* Signatures are valid for 14 days (`signature_validity`) and renewed when they would
|
||||
expire within 7 days (`resign_before`, checked hourly).
|
||||
* **Keep the primary running.** Secondaries serve the signatures they received; if the
|
||||
primary is down for longer than the remaining validity (7–14 days), the signatures on
|
||||
the secondaries expire and validating resolvers return SERVFAIL. Monitor that the
|
||||
primary is up (`easydns status`, `dns_zone_serial` – the serial grows with every
|
||||
re-signing) and watch the log for signing errors.
|
||||
* Check from time to time: `ednssec example.com SOA`, or dnsviz.
|
||||
|
||||
### 8. Key rollover (e.g. once a year, or immediately if the key leaked)
|
||||
|
||||
1. `easydns dnssec keygen --zone example.com --dir /etc/easydns/data/keys/example.com --algorithm ecdsap256`
|
||||
(a second key file appears), `easydns reload` – both keys are published and sign.
|
||||
2. Wait for the DNSKEY TTL (default 3600 s) so resolvers know the new key.
|
||||
3. `easydns dnssec ds …` now prints two DS lines: **add** the new DS at the registrar,
|
||||
keep the old one.
|
||||
4. Wait until the new DS is visible (`easydig @1.1.1.1 example.com DS`) plus the parent's
|
||||
DS TTL (the TTL shown in that answer; often 1 hour to 1 day).
|
||||
5. Remove the **old** DS at the registrar; wait the DS TTL again.
|
||||
6. Delete the old key file from the key directory, `easydns reload`.
|
||||
|
||||
Changing the algorithm (e.g. 15 → 13) works the same way, with the new key generated with
|
||||
the new `--algorithm` and `dnssec.algorithm` changed in step 1.
|
||||
|
||||
### 9. Turning DNSSEC off safely
|
||||
|
||||
Order matters – the other way round makes the domain fail for validating resolvers:
|
||||
1. Remove **all** DS records at the registrar.
|
||||
2. Wait until the DS is gone from the parent (`easydig @1.1.1.1 example.com DS +short`
|
||||
returns nothing) **and** its TTL has passed.
|
||||
3. Remove the `dnssec:` block from the zone definition, `easydns reload`.
|
||||
|
||||
### Moving a signed domain from BIND
|
||||
|
||||
BIND's private keys cannot be imported. Generate a new key in EasyDNS and use the
|
||||
rollover above with BIND still signing (add the new DS, switch the name servers or the
|
||||
primary, remove the old DS) – see [migration-from-bind.md](migration-from-bind.md#5-dnssec-signed-zones).
|
||||
|
||||
---
|
||||
|
||||
## Reference: signing primary zones
|
||||
|
||||
```yaml
|
||||
zones:
|
||||
- name: example.com
|
||||
type: primary
|
||||
file: zones/example.com.zone # stays unsigned
|
||||
dnssec:
|
||||
keys_dir: /etc/easydns/data/keys/example.com
|
||||
algorithm: ed25519 # ed25519 | ecdsap256 | ecdsap384 (13 = ecdsap256 is the most widely accepted by registrars)
|
||||
auto_generate: true # create a CSK if the directory is empty
|
||||
signature_validity: 14d
|
||||
resign_before: 7d
|
||||
```
|
||||
|
||||
* Keys: `easydns dnssec keygen --zone example.com --dir /etc/easydns/data/keys/example.com [--role ksk|zsk|csk]`;
|
||||
`easydns dnssec ds --zone example.com --dir ...` prints the DNSKEY and the DS to submit to the parent.
|
||||
* The signer adds DNSKEY, an NSEC chain (authoritative names and delegation points, no glue)
|
||||
and RRSIGs (KSK/CSK sign DNSKEY; ZSK/CSK sign everything else; delegation NS and glue are
|
||||
not signed; DS is). With DO=1 the server returns RRSIGs and NSEC proofs for NXDOMAIN,
|
||||
NODATA, wildcard expansions and unsigned delegations.
|
||||
* Every change (file reload, API, DDNS) re-signs and bumps the serial; an hourly task
|
||||
re-signs when signatures expire within `resign_before`. The signed zone is persisted in
|
||||
`<data_dir>/signed/` so a restart does not produce new signatures under the same serial.
|
||||
* Rollover: add the new key file, reload (both keys published and used), wait DNSKEY TTL
|
||||
(+ parent DS TTL for KSKs, after updating the DS), remove the old key file, reload.
|
||||
* Secondaries simply transfer the signed zone (signing on secondaries is rejected).
|
||||
|
||||
## Reference: validation
|
||||
|
||||
```yaml
|
||||
recursion: { enabled: true, dnssec_validation: true, trust_anchors: null } # null = IANA root KSK-2017 + KSK-2024
|
||||
```
|
||||
|
||||
* Chain of trust from the anchors: DNSKEY(anchor) verified against the anchor →
|
||||
DS(child) verified with the parent's keys → DNSKEY(child) matching a DS and self-signed →
|
||||
RRSIG over every answer RRset (inception/expiration, signer must enclose the owner).
|
||||
* Missing DS proven by signed NSEC/NSEC3 (incl. opt-out) → **insecure** (answer without AD).
|
||||
* Negative answers need a signed SOA and an NSEC/NSEC3 proof (NXDOMAIN: covering NSEC +
|
||||
wildcard denial; NSEC3: closest-encloser proof) → **secure**.
|
||||
* Wildcard answers need a proof that no closer name exists.
|
||||
* Anything that fails → **bogus** → SERVFAIL; with CD=1 the data is returned without AD.
|
||||
Reasons are logged (`DNSSEC validation failed (bogus)`) and counted (`dns_dnssec_bogus_total`).
|
||||
* Unsupported algorithms (e.g. Ed448) or NSEC3 iterations > 150 (RFC 9276) → insecure.
|
||||
* Responses to clients set AD only for secure data and only when the client sent DO or AD.
|
||||
|
||||
Diagnostics: `ednssec example.com A` shows each zone cut's state, key tags and the result.
|
||||
@@ -0,0 +1,30 @@
|
||||
# Forwarder
|
||||
|
||||
```yaml
|
||||
upstreams:
|
||||
strategy: fastest # round-robin | fastest | failover | random | priority
|
||||
timeout: 2s
|
||||
health_check_interval: 30s
|
||||
servers: ["tls://1.1.1.1#cloudflare-dns.com", "https://9.9.9.9/dns-query#dns.quad9.net", "192.168.1.1"]
|
||||
forward_zones:
|
||||
- domain: corp.internal
|
||||
upstreams: ["10.0.0.53", "10.0.0.54"]
|
||||
strategy: failover
|
||||
clients: ["10.0.0.0/8"] # optional: rule applies only to these clients
|
||||
fallback_recursion: false # true: recurse when all upstreams fail
|
||||
resolution: { default: forward } # or forwardthenrecursive
|
||||
```
|
||||
|
||||
* Up to three upstreams are tried per query in strategy order; SERVFAIL/REFUSED/NOTIMP/
|
||||
FORMERR/timeouts count as failures.
|
||||
* **Circuit breaker:** 3 consecutive failures open the circuit for 30 s, doubling up to 5 min;
|
||||
open upstreams are tried last; successful health checks close the circuit.
|
||||
* `fastest` uses an EWMA of the RTT with occasional exploration of the runner-up.
|
||||
* Logs and `easydns upstreams list` / `GET /api/v1/upstreams` show RTT, failures, circuit state
|
||||
and the reason an upstream was chosen.
|
||||
* Forwarded answers are cached in a namespace per rule; private forward zones are never
|
||||
sent to public upstreams or the root.
|
||||
* Identical concurrent questions are sent upstream once (query coalescing).
|
||||
* **Encrypted upstreams** (`tls://…#name`, `https://…#name`) keep their connections open:
|
||||
a DoT connection pool and a multiplexed HTTP/2 connection for DoH. Private CAs:
|
||||
`upstreams.tls_ca_file`. Full guide: [secure-dns.md](secure-dns.md).
|
||||
@@ -0,0 +1,40 @@
|
||||
# Hybrid
|
||||
|
||||
One process can be Primary for some zones, Secondary for others, forward private domains
|
||||
and recurse for everything else:
|
||||
|
||||
```yaml
|
||||
recursion: { enabled: true, allowed_clients: ["acl:lan"] }
|
||||
zones:
|
||||
- { name: example.com, type: primary, file: zones/example.com.zone }
|
||||
- { name: example.net, type: secondary, primaries: ["192.0.2.10:53"] }
|
||||
forward_zones:
|
||||
- { domain: corp.internal, upstreams: ["10.0.0.53"] }
|
||||
resolution:
|
||||
default: recursive
|
||||
views:
|
||||
- { name: lan, clients: ["10.0.0.0/8"] }
|
||||
- { name: world, clients: [any] }
|
||||
```
|
||||
|
||||
## Precedence (tested in `crates/dns-server/tests/resolver.rs`)
|
||||
|
||||
1. **Local authoritative zones** – the most specific zone visible in the client's view wins
|
||||
(`example.com` beats a forward rule for `com`); NXDOMAIN inside a local zone is final and
|
||||
the name is never sent upstream.
|
||||
2. **Recursion permission** – clients outside `recursion.allowed_clients` get REFUSED.
|
||||
3. **Local-only names** (`localhost`, `local`, `test`, `invalid`, `home.arpa`, `onion`,
|
||||
RFC 1918/6303 reverse zones, plus `recursion.local_only_suffixes`) → NXDOMAIN locally.
|
||||
A forward rule for such a name takes precedence (e.g. forwarding `home.arpa` to a router).
|
||||
4. **Allow/block policy.**
|
||||
5. **Conditional forwarding** – longest matching suffix (and client ACL).
|
||||
6. **Default resolution.**
|
||||
|
||||
Data spaces are separate: authoritative zones are never cached; each forwarding rule and
|
||||
the recursive resolver use their own cache namespace.
|
||||
|
||||
## Views (split horizon)
|
||||
|
||||
`zones[].views: [lan]` makes a zone visible only to clients of that view; the same zone
|
||||
name can be defined twice with different files for different views. Views are matched in
|
||||
order; the first match wins.
|
||||
@@ -0,0 +1,196 @@
|
||||
# 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/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>/secondary/ZONE.zone` to a zone file, 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
|
||||
@@ -0,0 +1,35 @@
|
||||
# Monitoring and logs
|
||||
|
||||
## Metrics (`metrics.listen`, default 127.0.0.1:9090, path `/metrics`)
|
||||
|
||||
| Metric | Labels |
|
||||
|---|---|
|
||||
| `dns_queries_total` | transport (udp, tcp, dot, doh) |
|
||||
| `dns_queries_by_type_total` | qtype (A, AAAA, …, OTHER) |
|
||||
| `dns_responses_total` | rcode (NOERROR, NXDOMAIN, SERVFAIL, …) |
|
||||
| `dns_answers_by_source_total` | source (authoritative, cache, recursive, forward, blocked, local, refused) |
|
||||
| `dns_query_duration_seconds` | histogram |
|
||||
| `dns_upstream_latency_seconds`, `dns_upstream_errors_total` | |
|
||||
| `dns_cache_hits_total`, `dns_cache_misses_total`, `dns_cache_evictions_total`, `dns_cache_entries` | |
|
||||
| `dns_blocked_total`, `dns_rate_limited_total`, `dns_malformed_total` | |
|
||||
| `dns_xfr_out_total`, `dns_xfr_out_refused_total`, `dns_notify_received_total`, `dns_notify_refused_total` | |
|
||||
| `dns_updates_total`, `dns_updates_refused_total`, `dns_tsig_failures_total` | |
|
||||
| `dns_dnssec_secure_total`, `dns_dnssec_insecure_total`, `dns_dnssec_bogus_total` | |
|
||||
| `dns_zone_serial`, `dns_zone_expired`, `dns_zone_last_sync_timestamp_seconds` | zone (bounded by configured zones) |
|
||||
| `dns_tcp_connections`, `dns_inflight_queries`, `process_resident_memory_bytes`, `process_start_time_seconds` | |
|
||||
|
||||
No label ever contains a queried name or a client address. A Grafana dashboard is in
|
||||
`deploy/grafana/easydns.json`.
|
||||
|
||||
## Logs
|
||||
|
||||
`tracing` with `logging.level` (error, warn, info, debug, trace or a filter such as
|
||||
`info,query=info`), text or JSON (`logging.format: json`) on stderr. Optional query log
|
||||
(`logging.query_log: true`): client (anonymised by default), name, type, RCODE, source,
|
||||
transport, latency and a note (upstream used, block reason). Audit entries use target
|
||||
`audit`, policy decisions target `policy`.
|
||||
|
||||
## Health
|
||||
|
||||
`/healthz` (metrics and API listeners), `/readyz` (API: all primary zones loaded),
|
||||
`/api/v1/health` (`degraded` when a secondary zone is expired).
|
||||
@@ -0,0 +1,205 @@
|
||||
# Operating EasyDNS: master (primary) and name resolution
|
||||
|
||||
Example names only (`example.com`, `example.net`, documentation IP ranges).
|
||||
|
||||
---
|
||||
|
||||
## Part 1 – Running as master (primary)
|
||||
|
||||
### 1.1 Minimal public master
|
||||
|
||||
```yaml
|
||||
# /etc/easydns/config.yaml
|
||||
include: ["zones.d/*.yaml"]
|
||||
server:
|
||||
mode: primary
|
||||
listen: ["0.0.0.0:53", "[::]:53"]
|
||||
data_dir: /etc/easydns/data
|
||||
recursion: { enabled: false }
|
||||
resolution: { default: refuse } # authoritative only: foreign names → REFUSED
|
||||
rate_limit: { enabled: true, per_client_qps: 100, burst: 200, slip: 2 }
|
||||
api: { listen: "127.0.0.1:9953" } # the CLI uses the local control token automatically
|
||||
```
|
||||
```yaml
|
||||
# /etc/easydns/zones.d/example.com.yaml
|
||||
- name: example.com
|
||||
type: primary
|
||||
file: zones/example.com.zone # = /etc/easydns/data/zones/example.com.zone
|
||||
transfer_acl: ["198.51.100.20/32"] # IP only; a TSIG key is optional
|
||||
notify: ["198.51.100.20:53"]
|
||||
serial_strategy: date # YYYYMMDDnn for API/DDNS changes
|
||||
```
|
||||
```
|
||||
; /etc/easydns/data/zones/example.com.zone
|
||||
$TTL 3600
|
||||
@ IN SOA ns1.example.com. hostmaster.example.com. (
|
||||
2026112101 ; serial
|
||||
3600 ; refresh – how often secondaries check (without NOTIFY)
|
||||
600 ; retry – after a failed check
|
||||
1209600 ; expire – secondaries stop answering after 14 days without contact
|
||||
300 ) ; negative TTL (NXDOMAIN/NODATA caching)
|
||||
IN NS ns1.example.com.
|
||||
IN NS ns2.example.com. ; the secondary
|
||||
IN MX 10 mail
|
||||
ns1 IN A 192.0.2.10
|
||||
ns2 IN A 198.51.100.20
|
||||
www IN A 192.0.2.80
|
||||
```
|
||||
The zone file and definition above can be generated with
|
||||
`easydns zone create example.com --ns ns1.example.com=192.0.2.10 --ns ns2.example.com=198.51.100.20 --allow-transfer 198.51.100.20 --notify 198.51.100.20`.
|
||||
Validate and start: `easydns check-config` (also parses every zone), `systemctl enable --now easydns`.
|
||||
|
||||
### 1.2 Three ways to change a zone
|
||||
|
||||
| Way | When | What happens |
|
||||
|---|---|---|
|
||||
| **Edit the file** + raise the serial + `easydns reload` | manual administration, Git-managed zones | the file is re-read; if the content changed and the serial is newer, the new version is published atomically, the diff goes to the IXFR journal and NOTIFY is sent. A changed file with an old serial is **rejected** (old version stays). |
|
||||
| **REST API** (`POST/PUT/DELETE /api/v1/zones/{zone}/records`) | automation, panels, CI | serial bumped by `serial_strategy`, zone validated, file rewritten atomically (canonical form, comments lost), journal + NOTIFY. `If-Match` protects against concurrent edits. |
|
||||
| **Dynamic update** (RFC 2136, `nsupdate`, DHCP, ACME clients) | machines updating their own records | by source IP (`update_acl`), by key (`update_keys`) or per record (`update_policy`, BIND syntax) – see [primary.md](primary.md#dynamic-updates-rfc-2136); prerequisites supported; audited. |
|
||||
|
||||
Do not mix manual file edits with API/DDNS on the same zone without care: after an API
|
||||
change the file on disk is the canonical version – edit that, not an old copy.
|
||||
|
||||
```bash
|
||||
nsupdate -y hmac-sha256:ddns-key:$(cat ddns.secret) <<'EOF2'
|
||||
server 192.0.2.10
|
||||
zone example.com
|
||||
update delete host1.example.com A
|
||||
update add host1.example.com 300 A 192.0.2.55
|
||||
send
|
||||
EOF2
|
||||
```
|
||||
|
||||
### 1.3 Adding and removing zones
|
||||
|
||||
* **Files:** drop `zones.d/<zone>.yaml` + the zone file, `easydns reload`. Remove = delete the
|
||||
file + reload (the zone stops being served immediately; remember to remove it from secondaries).
|
||||
* **API:** `POST /api/v1/zones` (stored in `<data_dir>/api-overlay.yaml`), `DELETE` removes only API-created zones.
|
||||
|
||||
### 1.4 What clients receive
|
||||
|
||||
* answers from the zone with the **AA** flag; NXDOMAIN/NODATA with the SOA (negative TTL =
|
||||
min(SOA TTL, SOA minimum));
|
||||
* wildcards (`*.apps IN A …`) expand for names that do not exist; empty non-terminals give NODATA;
|
||||
* delegations (`sub IN NS …`) give referrals (no AA) with glue;
|
||||
* MX/NS/SRV targets inside the zone are added to the additional section;
|
||||
* with DNSSEC signing (`dnssec:` in the zone) and the DO bit: RRSIGs and NSEC proofs.
|
||||
|
||||
### 1.5 Secondaries, NOTIFY and IXFR
|
||||
|
||||
After every published change the primary sends NOTIFY (3 attempts with back-off) to
|
||||
`notify:` targets. Secondaries ask for IXFR from their serial; the journal (`journal_size`,
|
||||
default 100 versions) answers incrementally, older serials get the whole zone. Watch:
|
||||
`easydns zones transfers example.com`, metric `dns_xfr_out_total`, `dns_xfr_out_refused_total`.
|
||||
All authentication variants: [zone-transfer-variants.md](zone-transfer-variants.md).
|
||||
|
||||
### 1.6 Daily operations
|
||||
|
||||
| Task | Command |
|
||||
|---|---|
|
||||
| status of all zones | `easydns zones list` / `easydns status` |
|
||||
| details (serial, last change, errors) | `easydns zones show example.com` |
|
||||
| force NOTIFY | `easydns zones notify example.com` |
|
||||
| check a zone before reloading | `easyzone check /etc/easydns/data/zones/example.com.zone -o example.com` |
|
||||
| compare primary with secondaries | `easydiff example.com SOA @192.0.2.10 @198.51.100.20` |
|
||||
| DS for the registrar (signed zone) | `easydns dnssec ds --zone example.com --dir /etc/easydns/data/keys/example.com` |
|
||||
| audit of changes | `GET /api/v1/audit` or `<data_dir>/audit.log` |
|
||||
|
||||
---
|
||||
|
||||
## Part 2 – Name resolution (resolver)
|
||||
|
||||
### 2.1 How EasyDNS answers a query
|
||||
|
||||
For each query the server walks this decision list (first match wins):
|
||||
|
||||
1. **Local zone** (primary or secondary, most specific, visible in the client's view) →
|
||||
authoritative answer. Names under a local zone are never looked up elsewhere.
|
||||
2. Client **not allowed** to use resolution (`recursion.allowed_clients`) → REFUSED.
|
||||
3. **Local-only names** (`localhost`, `local`, `test`, `invalid`, `home.arpa`, private
|
||||
reverse zones, `recursion.local_only_suffixes`) → NXDOMAIN, nothing leaves the host.
|
||||
4. **Block/allow lists** → NXDOMAIN / REFUSED / 0.0.0.0 according to `policy.block_action`.
|
||||
5. **Conditional forwarding** (`forward_zones`, longest suffix) → the configured upstreams.
|
||||
6. **Default:** `recursive` (iterative from the root), `forward` (upstreams),
|
||||
`forwardthenrecursive`, or `refuse`.
|
||||
|
||||
### 2.2 Iterative resolution step by step
|
||||
|
||||
Query `www.example.com A` with an empty cache:
|
||||
```
|
||||
client ──► EasyDNS
|
||||
├─► root server (from root hints) "com" ? → referral to com NS + glue
|
||||
├─► com server "example.com" ? → referral to example.com NS
|
||||
└─► example.com server "www.example.com A" → answer (AA)
|
||||
client ◄── answer (RA=1, AA=0), cached for its TTL
|
||||
```
|
||||
* With **QNAME minimisation** the root only learns `com`, the TLD only `example.com`.
|
||||
* Every response is checked: only records inside the zone of the server that sent them are
|
||||
accepted (bailiwick), glue only for names inside the delegating zone, IDs/ports random.
|
||||
* Glueless delegations (NS names in another zone) are resolved first; CNAMEs are followed
|
||||
across zones (max `max_cname_chain`).
|
||||
* Limits per query: `max_queries` upstream queries, `max_depth` referrals, `total_timeout`.
|
||||
* With `dnssec_validation: true` every answer is validated from the root trust anchor:
|
||||
secure → AD flag for clients that ask (DO/AD), insecure → plain answer, bogus → SERVFAIL
|
||||
(unless the client sets CD).
|
||||
* The second identical query is answered from cache (`dns_cache_hits_total`); delegations
|
||||
are cached too, so `mail.example.com` goes straight to the example.com servers.
|
||||
|
||||
Watch it live: `easytrace www.example.com` (each referral with timing) or
|
||||
`easydnssec www.example.com` (chain of trust).
|
||||
|
||||
### 2.3 Typical resolver setups
|
||||
|
||||
**LAN resolver (recursive, validating):**
|
||||
```yaml
|
||||
server: { mode: recursive, listen: ["192.168.1.2:53", "127.0.0.1:53"] }
|
||||
recursion:
|
||||
enabled: true
|
||||
allowed_clients: ["127.0.0.0/8", "192.168.0.0/16"]
|
||||
dnssec_validation: true
|
||||
resolution: { default: recursive }
|
||||
cache: { max_entries: 200000 }
|
||||
```
|
||||
|
||||
**Resolver + local zones + private company domain (hybrid):**
|
||||
```yaml
|
||||
include: ["zones.d/*.yaml"] # e.g. home.example.com as primary
|
||||
recursion: { enabled: true, allowed_clients: ["acl:lan"], dnssec_validation: true }
|
||||
acls: { lan: ["192.168.0.0/16", "10.8.0.0/24"] }
|
||||
forward_zones:
|
||||
- { domain: corp.example.net, upstreams: ["10.0.0.53", "10.0.0.54"], strategy: failover }
|
||||
resolution: { default: recursive }
|
||||
policy: { blocklists: [ { name: ads, url: "https://lists.example/ads.txt" } ] }
|
||||
```
|
||||
|
||||
**Forwarder to encrypted upstreams (no own recursion):**
|
||||
```yaml
|
||||
upstreams:
|
||||
strategy: fastest
|
||||
servers: ["tls://1.1.1.1#cloudflare-dns.com", "tls://9.9.9.9#dns.quad9.net"]
|
||||
resolution: { default: forward }
|
||||
```
|
||||
|
||||
**Forward first, recurse if upstreams fail:** `resolution: { default: forwardthenrecursive }`.
|
||||
|
||||
### 2.4 Answers clients can expect
|
||||
|
||||
| Situation | RCODE / flags |
|
||||
|---|---|
|
||||
| name resolved | NOERROR, RA=1, AA=0 (AD=1 if validated and requested) |
|
||||
| name in a local zone | NOERROR/NXDOMAIN with AA=1 |
|
||||
| name does not exist | NXDOMAIN + SOA (cached for the negative TTL) |
|
||||
| type does not exist | NOERROR, empty answer + SOA |
|
||||
| client not allowed | REFUSED, RA=0 |
|
||||
| blocked name | per `block_action` (default NXDOMAIN) |
|
||||
| upstream/authority unreachable, DNSSEC bogus | SERVFAIL (cached 5 s; stale data if `serve_stale`) |
|
||||
|
||||
### 2.5 Troubleshooting resolution
|
||||
|
||||
```bash
|
||||
easydig @127.0.0.1 www.example.com +dnssec # what the resolver returns, with AD/RRSIG
|
||||
easytrace www.example.com # where the delegation chain breaks
|
||||
easydnssec www.example.com # which link of the chain of trust fails
|
||||
easydiff www.example.com A @127.0.0.1 @9.9.9.9 # compare with a public resolver
|
||||
easydns cache clear --domain example.com # drop cached data for one domain
|
||||
```
|
||||
@@ -0,0 +1,175 @@
|
||||
# Performance: EasyDNS vs BIND 9 (estimates)
|
||||
|
||||
> **These are estimates, not benchmark results.** Only one EasyDNS figure below was
|
||||
> measured; all BIND figures come from ISC's published Perflab results, and the comparison
|
||||
> is derived from the architecture of both servers. Measure on your own hardware before
|
||||
> sizing production (see "How to measure").
|
||||
|
||||
## Reference points
|
||||
|
||||
| Source | Figure |
|
||||
|---|---|
|
||||
| EasyDNS 0.1.0, **measured** (docs/testing.md) | 54 600 QPS, authoritative A answers from a small zone over UDP, 2 vCPU container, load generator on the same 2 vCPUs; p50/p95/p99 = 0.87/1.43/1.89 ms; RSS 13 MB |
|
||||
| ISC Perflab, BIND 9.20, 96-core servers ([ISC: BIND Authoritative Performance on Multi-core Systems](https://victor.isc.org/blogs/2026-09-03-new-perflab/)) | about 1 million QPS at about 30 cores (read from a chart); scaling flattens above ~16 cores. |
|
||||
| ISC Perflab, BIND 9.20 vs 9.18 ([ISC, Dec 2025](https://www.isc.org/blogs/bind-auth-performance-december-2025/)) | 9.20 is 4–7 % faster than 9.18 for most authoritative profiles |
|
||||
|
||||
Averaged over 30 cores that is roughly 33 000 QPS per core for BIND 9.20. Per-core
|
||||
throughput at low core counts is typically higher than this average.
|
||||
|
||||
## Estimated throughput – authoritative, small zone, UDP
|
||||
|
||||
| Cores | BIND 9.20 (estimate) | EasyDNS 0.1 (estimate) | EasyDNS / BIND |
|
||||
|---|---|---|---|
|
||||
| 1 | 40–70 k QPS | 30–45 k QPS | ~65–75 % |
|
||||
| 2 | 80–130 k | 60–90 k (55 k measured with the load generator sharing the CPUs) | ~70 % |
|
||||
| 4 | 150–250 k | 100–150 k | ~60 % |
|
||||
| 8 | 300–450 k | 130–200 k | ~40–45 % |
|
||||
| 16+ | 500 k – 1 M | 150–250 k (plateau) | ~25–30 % |
|
||||
|
||||
Why EasyDNS keeps up on small machines but falls behind on large ones:
|
||||
* a Tokio task per packet and allocation-heavy decode/encode (hickory `Message`);
|
||||
* answers are built per query (no pre-rendered wire answers);
|
||||
* no `recvmmsg`/`sendmmsg` batching (one system call per packet).
|
||||
|
||||
The table above describes 0.1.0. See "Changes after 0.1.0" for what has been removed
|
||||
from this list and what was measured.
|
||||
|
||||
## Changes after 0.1.0 (Unreleased)
|
||||
|
||||
| Change | Effect |
|
||||
|---|---|
|
||||
| **UDP socket group with SO_REUSEPORT** (`server.udp_sockets`, default one per CPU, max 16) | the kernel spreads queries over N sockets, each with its own receive loop: receiving is no longer serialised on one task. This was the main plateau above ~4 cores. |
|
||||
| **Sharded cache** (16 locks instead of one; records copied after the lock is released) | cache hits from many cores no longer queue on one lock; boxed slices drop spare `Vec` capacity per entry |
|
||||
| **Rate limiter**: client buckets in 16 shards, server-wide limit as a lock-free atomic (GCRA) | rate limiting (on by default) no longer takes two global locks per UDP query |
|
||||
| `rate_limit.global_qps` default changed from 100 000 to **0 = no server-wide cap** | the old default capped every server at 100 k QPS regardless of hardware; per-client limits still apply |
|
||||
| **Query coalescing** (forwarder and recursion) | N identical concurrent cache misses cost one upstream resolution; the others wait for its answer |
|
||||
| No `String` allocation per query for metrics | small per-query saving |
|
||||
|
||||
Measured on the same 2-vCPU container as before (load generator sharing the CPUs,
|
||||
`ebench -c 50`, 3 × 8 s runs):
|
||||
|
||||
| Build | QPS | p99 | RSS |
|
||||
|---|---|---|---|
|
||||
| 0.1.0 | 55 800 – 56 800 | 1.76 – 1.86 ms | 12.0 MB |
|
||||
| Unreleased, `udp_sockets: 1` | 56 000 – 57 200 | 1.70 – 1.82 ms | 12.7 MB |
|
||||
| Unreleased, `udp_sockets: 0` (2 sockets) | 59 400 – 60 100 | 1.74 – 1.76 ms | 12.3 MB |
|
||||
|
||||
That is about +6 % on 2 vCPUs. The changes target many-core machines, which this
|
||||
container cannot show; the multi-core gain is **expected, not measured**. Revised
|
||||
estimates for authoritative UDP (to be confirmed with dnsperf on real hardware):
|
||||
|
||||
| Cores | EasyDNS 0.1 (estimate) | Unreleased (estimate) | vs BIND 9.20 |
|
||||
|---|---|---|---|
|
||||
| 1–2 | 30–90 k | 30–95 k | ~70 % |
|
||||
| 4 | 100–150 k | 120–180 k | ~70 % |
|
||||
| 8 | 130–200 k | 220–320 k | ~65–70 % |
|
||||
| 16+ | 150–250 k (plateau) | 350–550 k | ~50–60 % |
|
||||
|
||||
Memory: the socket group adds about 4 KiB of user-space buffer per socket; the kernel
|
||||
receive/send buffers (1 MiB requested, capped by `net.core.rmem_max`/`wmem_max`) are only
|
||||
filled while packets are queued. The cache and rate limiter keep the same entry limits as
|
||||
before (cache `max_entries` is split across the shards; the limiter tracks at most 100 000
|
||||
client prefixes in total). Coalescing holds one small waiter per waiting query, at most
|
||||
1 024 per name.
|
||||
|
||||
At typical real-world loads (a few thousand QPS per server) both are far below their
|
||||
limits; latency at low load is similar (sub-millisecond on a LAN).
|
||||
|
||||
## Round 2 (Unreleased): encoded-answer cache, batched UDP, prefetch
|
||||
|
||||
| Change | What it does |
|
||||
|---|---|
|
||||
| **Encoded-answer cache** (`cache.answer_entries`, default 20 000) | identical queries are answered by copying stored response bytes and patching ID, question case and (for resolved data) TTLs – no parsing, policy, lookup or encoding. Invalidated at once by any zone change, reload or cache flush; client profile (view, ACL, block-list exemption, forward rules, transport) is part of the key. See [configuration.md](configuration.md#encoded-answer-cache-cacheanswer_entries). |
|
||||
| **UDP fast path** | cache hits are answered inside the receive loop – no task spawned per packet |
|
||||
| **Batched UDP on Linux** (`recvmmsg`/`sendmmsg`, 32 packets per call) | fewer system calls when packets queue up under heavy load |
|
||||
| **Resolver prefetch** (`cache.prefetch`, default on) | popular entries (≥ 2 hits, TTL ≥ 20 s) are refreshed in the background in the last 10 % of their TTL, so clients do not wait for re-resolution of popular names; for recursion and forwarding |
|
||||
| Zone path normalisation | `file: ../x.zone` works before the data directory exists |
|
||||
|
||||
### Measured (2-vCPU container, release build, load generator on the same CPUs)
|
||||
|
||||
The load generator takes about half of the two CPUs, so QPS understates the server's
|
||||
gain. The meaningful number is the **server CPU time per answered query** (from
|
||||
`/proc/<pid>/stat` over 10 s of `ebench -c 50`):
|
||||
|
||||
| Workload | Answer cache off | Answer cache on | Change |
|
||||
|---|---|---|---|
|
||||
| One name repeated (best case) | 14.4–14.8 µs/query ≈ 68 k QPS per core | 6.3–6.7 µs/query ≈ **150 k QPS per core** | **2.2×** |
|
||||
| Realistic mix: 10 000 names, 80 % A / 10 % MX / 10 % random NXDOMAIN | 14.4–16.0 µs ≈ 65 k QPS per core | 8.7–9.3 µs ≈ **110 k QPS per core** | **1.65×** |
|
||||
| Forwarder answering from its cache (resolver/forwarder hot path) | 14.5–14.9 µs ≈ 68 k QPS per core | 6.4–6.8 µs ≈ **150 k QPS per core** | **2.2×** |
|
||||
| QPS seen by the generator (single name) | ~57 k | ~70 k | +22 % |
|
||||
| p99 latency (single name) | 1.8–2.0 ms | 1.4–1.5 ms | −25 % |
|
||||
| RSS | 12.9 MB | 11.4 MB | – |
|
||||
|
||||
Batched `recvmmsg`/`sendmmsg` showed **no measurable gain in this setup**: the generator
|
||||
waits for each answer, so batches hold 1–2 packets (confirmed with `strace -c`: one
|
||||
`recvmmsg` and one `sendmmsg` per ~1.3 queries). It pays off only when packets queue in
|
||||
the socket under real load; it does not cost anything measurable at low batch sizes.
|
||||
|
||||
### Updated estimate vs BIND 9.20 (authoritative UDP) – not measured on multi-core yet
|
||||
|
||||
Per core, EasyDNS now spends about 6–9 µs per answered query on cacheable traffic.
|
||||
BIND's published figure of roughly 1 M QPS on ~30 cores is ~33 k QPS per core on that
|
||||
hardware (more per core at low core counts). The two numbers come from different
|
||||
machines and methods, so they are **not directly comparable**; the realistic reading:
|
||||
|
||||
| Traffic | Before round 2 | Now (estimate) |
|
||||
|---|---|---|
|
||||
| Repeated queries (typical authoritative traffic, popular names) | ~70 % of BIND per core | **about BIND's level, possibly above** on few cores |
|
||||
| Unique names / random-subdomain floods (cache misses) | ~65–70 % | unchanged: ~65–70 % (full parse + lookup + encode) |
|
||||
| Scaling to 8–16 cores | estimated 65–70 % (SO_REUSEPORT, round 1) | similar or better; shared structures are sharded, but contention was not measured |
|
||||
|
||||
To replace these estimates with facts run `scripts/bench-vs-bind.sh` on a machine with
|
||||
8+ cores: it starts BIND and EasyDNS with the same 10 000-record zone on the same pinned
|
||||
cores and drives both with `dnsperf` (80 % existing names, 10 % MX, 10 % random
|
||||
NXDOMAIN), reporting QPS, latency, loss and RSS for BIND, EasyDNS and EasyDNS with the
|
||||
answer cache off.
|
||||
|
||||
## Other workloads (estimates)
|
||||
|
||||
| Workload | Comparison | Reason |
|
||||
|---|---|---|
|
||||
| Recursive, **cache hit** | 0.1: ~50–70 % of BIND on 1–4 cores, falling behind on more cores. Unreleased: sharded cache, expected to scale with cores | 0.1 had a single-lock cache |
|
||||
| Recursive, **cache miss** | latency similar (dominated by network RTT); EasyDNS sends more upstream queries (0.1: ~10–30 %; coalescing now removes duplicates for identical concurrent questions) | no prefetch, no aggressive NSEC use (RFC 8198), simpler server selection; coalescing covers whole client questions, not the resolver's internal NS-address lookups |
|
||||
| DNSSEC validation | similar per-signature cost (ring); EasyDNS caches zone key states 300 s | key cache with fixed TTL |
|
||||
| Zone transfers (AXFR/IXFR) | comparable for small and medium zones | 16 KiB messages, journal-based IXFR on both sides |
|
||||
| Large zones (≥ 1 M records): load time | EasyDNS ~2–4× slower | text parser + per-record allocation |
|
||||
| Large zones: memory | EasyDNS ~2–3× BIND (≈ 300–500 B/record vs ≈ 150–250 B) | `Record` objects with owned names in hash maps (BIND 9.20: qp-trie) |
|
||||
| Idle memory | EasyDNS ~10–20 MB, BIND ~30–80 MB | small runtime, no preallocated pools |
|
||||
| DoT | comparable per connection | rustls; TCP_NODELAY fixed (Unreleased: new connection 44 ms → 0.5 ms on loopback) |
|
||||
| DoH | comparable (Unreleased) | HTTP/2 multiplexing like BIND; 0.1.0 had HTTP/1.1 only |
|
||||
| Encrypted forwarding (DoT/DoH upstreams) | Unreleased: persistent connections – 0.06 ms (DoT) / 0.13 ms (DoH h2) per query on loopback vs ~0.5 ms with a handshake per query | see [secure-dns.md](secure-dns.md) |
|
||||
| Reload of one changed zone | faster in EasyDNS | only changed zones are re-published (atomic pointer swap); BIND `rndc reload` re-reads all zones |
|
||||
|
||||
## Planned improvements (by expected impact)
|
||||
|
||||
Done: SO_REUSEPORT socket group, sharded cache and rate limiter, query coalescing
|
||||
(round 1); encoded-answer cache with UDP fast path, batched UDP on Linux, resolver
|
||||
prefetch (round 2).
|
||||
|
||||
1. Measure on 8–32 cores with `scripts/bench-vs-bind.sh` and update the tables above.
|
||||
2. Cache-miss path: allocation-free parsing of plain queries and pre-encoded RRsets in
|
||||
zones (helps unique names and random-subdomain floods) – needs a fuzzing campaign.
|
||||
3. Compact zone storage (name interning or trie) for large zones.
|
||||
4. Resolver: aggressive use of NSEC/NSEC3 (RFC 8198), coalescing of internal lookups.
|
||||
|
||||
## How to measure
|
||||
|
||||
Automated comparison on one machine (needs `dnsperf`, `bind9`, a release build):
|
||||
```bash
|
||||
scripts/bench-vs-bind.sh --cores 8 --duration 30 --clients 200
|
||||
# → bench-results/bench-<date>.md: BIND / EasyDNS / EasyDNS without answer cache
|
||||
```
|
||||
Server CPU time per query (works on small machines, where the generator competes for
|
||||
CPUs): compare `utime+stime` from `/proc/<pid>/stat` before and after a run.
|
||||
|
||||
Manual: run both servers on the **same machine** with the same zone, and the load generator on
|
||||
another machine:
|
||||
|
||||
```bash
|
||||
easybench @SERVER -d queries.txt --qps 0 --duration 60s -c 200 --i-own-this-server --json
|
||||
dnsperf -s SERVER -d queries.txt -l 60 -c 200 -Q 1000000 # BIND's tool, for cross-checks
|
||||
resperf -s SERVER -d queries.txt -m 200000 # resolver capacity ramp
|
||||
```
|
||||
|
||||
Record cores, CPU model, kernel, QPS, p50/p95/p99, lost queries, CPU and RSS
|
||||
(`process_resident_memory_bytes`), and the cache hit ratio for resolvers.
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
# Primary (master)
|
||||
|
||||
A primary serves zones from zone files (BIND format) stored in
|
||||
`/etc/easydns/data/zones/`, sends NOTIFY to its secondaries, serves AXFR/IXFR and accepts
|
||||
RFC 2136 dynamic updates when allowed.
|
||||
|
||||
## Quick start
|
||||
|
||||
```bash
|
||||
easydns zone create example.com --ns ns1.example.com=192.0.2.10 --ns ns2.example.net \
|
||||
--ip 192.0.2.80 --allow-transfer 198.51.100.20 --notify 198.51.100.20 --reload
|
||||
```
|
||||
This writes `/etc/easydns/data/zones/example.com.zone` and
|
||||
`/etc/easydns/zones.d/example.com.yaml` (see [cli-tools.md](cli-tools.md#creating-a-zone)).
|
||||
|
||||
## Zone definition
|
||||
|
||||
```yaml
|
||||
zones:
|
||||
- name: example.com
|
||||
type: primary
|
||||
file: zones/example.com.zone # relative to data_dir → /etc/easydns/data/zones/example.com.zone
|
||||
transfer_acl: ["198.51.100.20/32"] # secondaries allowed to AXFR/IXFR (default: nobody)
|
||||
notify: ["198.51.100.20:53"] # NOTIFY after every change
|
||||
serial_strategy: increment # increment | unixtime | date (YYYYMMDDnn)
|
||||
journal_size: 100 # IXFR history
|
||||
# optional:
|
||||
# transfer_tsig_key: xfr-key # also require a TSIG key for transfers
|
||||
# notify_tsig_key: xfr-key # sign NOTIFY
|
||||
# dnssec: { keys_dir: /etc/easydns/data/keys/example.com } # see dnssec.md
|
||||
```
|
||||
|
||||
No key is needed: transfers are authorised by the secondaries' IP addresses. All
|
||||
variants (with or without TSIG, hidden primary, BIND interop) are in
|
||||
[zone-transfer-variants.md](zone-transfer-variants.md).
|
||||
|
||||
* **Loading/validation:** exactly one SOA at the apex, NS at the apex, no CNAME with other
|
||||
data, no out-of-zone data, class IN. Errors abort startup (or keep the old version on reload).
|
||||
* **Changing a zone file:** edit, increase the serial, `easydns reload`. A changed file with a
|
||||
serial that is not RFC 1982-newer is rejected and the old zone keeps being served.
|
||||
* **API / DDNS changes** bump the serial automatically, write the zone file atomically,
|
||||
publish the new snapshot, append the diff to the IXFR journal and send NOTIFY.
|
||||
* **AXFR/IXFR:** TCP only for AXFR; IXFR over UDP answers the SOA (client retries over TCP).
|
||||
IXFR uses the journal; if the client's serial is not in the journal an AXFR-style response
|
||||
is sent (RFC 1995 fallback). With TSIG every message of the stream is signed.
|
||||
* **Wildcards** (RFC 4592), **empty non-terminals**, **delegations with glue**, **DS at the cut**,
|
||||
additional-section processing for MX/NS/SRV targets.
|
||||
* Transfer statistics: `GET /api/v1/zones/{zone}/transfers`, `easydns zones transfers <zone>`.
|
||||
* Queries are answered for everyone (`allow-query { any; }` is the default for
|
||||
authoritative data); recursion is a separate, ACL-restricted function.
|
||||
|
||||
## Dynamic updates (RFC 2136)
|
||||
|
||||
Dynamic updates are off until one of three models is configured per zone. They work
|
||||
with standard clients: `nsupdate`, ISC/Kea DHCP, certbot `dns-rfc2136`, acme.sh
|
||||
`dns_nsupdate`, lego `rfc2136`, Home Assistant, routers with RFC 2136 DDNS.
|
||||
|
||||
| Model | Configuration | BIND equivalent |
|
||||
|---|---|---|
|
||||
| **IP only, no key** | `update_acl: [addresses]` (alias `allow_update`) | `allow-update { 192.0.2.7; };` |
|
||||
| **Key, whole zone** | `update_keys: [key]` (+ optional `update_acl`) | `allow-update { key k; };` |
|
||||
| **Per-record rules** | `update_policy: ["grant …", …]` (+ optional `update_acl`) | `update-policy { grant …; };` |
|
||||
|
||||
`update_policy` and `update_keys` cannot be combined (as in BIND). When `update_acl` is
|
||||
set together with keys or a policy, the source address must match **as well**.
|
||||
Every accepted and refused update is written to the audit log
|
||||
(`<data_dir>/audit.log`, `GET /api/v1/audit`) and counted in `dns_updates_total` / `dns_updates_refused_total`.
|
||||
|
||||
### Model 1 – IP-based updates, no keys
|
||||
|
||||
```yaml
|
||||
- name: example.com
|
||||
type: primary
|
||||
file: zones/example.com.zone
|
||||
update_acl: ["198.51.100.50", "203.0.113.2"] # these hosts may change any record
|
||||
```
|
||||
```bash
|
||||
nsupdate <<'EOF'
|
||||
server 192.0.2.10
|
||||
zone example.com
|
||||
update delete host.example.com A
|
||||
update add host.example.com 300 A 192.0.2.77
|
||||
send
|
||||
EOF
|
||||
```
|
||||
Unsigned updates are trusted by source address only. UDP source addresses can be spoofed
|
||||
on networks without anti-spoofing filters, so keep the list short (single hosts, not
|
||||
networks), limit port 53 with a firewall, or use a key for anything reachable from the
|
||||
Internet. `easydns check-config` refuses `update_acl: [any]` without a key.
|
||||
|
||||
### Model 2 – one key for the whole zone
|
||||
|
||||
```yaml
|
||||
- name: example.com
|
||||
type: primary
|
||||
file: zones/example.com.zone
|
||||
update_keys: [ddns-key]
|
||||
update_acl: ["192.168.1.0/24"] # optional extra restriction
|
||||
```
|
||||
|
||||
### Model 3 – per-record rules (`update_policy`, BIND `update-policy`)
|
||||
|
||||
Rules are written exactly as in BIND (without the trailing `;`):
|
||||
|
||||
```
|
||||
grant|deny <key name> <rule type> [<name>] [<types> ...]
|
||||
```
|
||||
|
||||
| Rule type | Matches records whose owner is… | Needs `<name>` |
|
||||
|---|---|---|
|
||||
| `name` | exactly `<name>` | yes |
|
||||
| `subdomain` | `<name>` or anything below it | yes |
|
||||
| `wildcard` | anything strictly below `<name>` (written `*.dyn.example.com.`) | yes |
|
||||
| `zonesub` | anywhere in the zone | no |
|
||||
| `self` | equal to the key name | no (BIND's placeholder `*` is accepted) |
|
||||
| `selfsub` | the key name or below it | no |
|
||||
|
||||
* Types: a list such as `TXT` or `A AAAA` (case-insensitive). No list = every type except
|
||||
SOA, NS, RRSIG, NSEC, NSEC3 (as in BIND); `ANY` = every type, including deleting all
|
||||
RRsets at a name.
|
||||
* Identity: the TSIG key name; `*` = any key known to the server.
|
||||
* Every record of an update must be granted; the **first matching rule** decides
|
||||
(`deny` rules can carve out exceptions). Unsigned updates are refused.
|
||||
* Not supported: Kerberos/GSS identities (`krb5-*`, `ms-*`), `tcp-self`, `6to4-self`,
|
||||
`external` – `check-config` reports them as errors instead of ignoring them.
|
||||
|
||||
#### Example: translating a BIND master zone
|
||||
|
||||
BIND (names and addresses changed to documentation examples):
|
||||
```
|
||||
zone "example.com" {
|
||||
type master;
|
||||
file "/etc/bind/example.com.conf";
|
||||
notify yes;
|
||||
allow-transfer { 198.51.100.10; 198.51.100.11; 203.0.113.20; 127.0.0.1; };
|
||||
also-notify { 198.51.100.11; 203.0.113.20; };
|
||||
update-policy {
|
||||
grant wildcard.h.example.com. zonesub TXT;
|
||||
grant wildcard.h.example.com. name _acme-challenge.app1.h.example.com. TXT;
|
||||
grant certbot-key. name _acme-challenge.example.com. txt;
|
||||
grant certbot-key. name _acme-challenge.ns1.example.com. txt;
|
||||
grant ddns.example.com. name h.ddns.example.com. A;
|
||||
};
|
||||
allow-query { any; };
|
||||
};
|
||||
```
|
||||
|
||||
EasyDNS – `/etc/easydns/zones.d/example.com.yaml`:
|
||||
```yaml
|
||||
- name: example.com
|
||||
type: primary
|
||||
file: zones/example.com.zone # copy of /etc/bind/example.com.conf into /etc/easydns/data/zones/
|
||||
transfer_acl: ["198.51.100.10", "198.51.100.11", "203.0.113.20", "127.0.0.1"]
|
||||
notify: ["198.51.100.11:53", "203.0.113.20:53"] # notify yes + also-notify
|
||||
update_policy:
|
||||
- "grant wildcard.h.example.com. zonesub TXT"
|
||||
- "grant wildcard.h.example.com. name _acme-challenge.app1.h.example.com. TXT"
|
||||
- "grant certbot-key. name _acme-challenge.example.com. TXT"
|
||||
- "grant certbot-key. name _acme-challenge.ns1.example.com. TXT"
|
||||
- "grant ddns.example.com. name h.ddns.example.com. A"
|
||||
# update_acl: ["198.51.100.50"] # optional: additionally require these source addresses
|
||||
```
|
||||
`allow-query { any; }` needs no setting (authoritative answers are public by default).
|
||||
|
||||
The keys named in the rules are copied from BIND **unchanged** into
|
||||
`/etc/easydns/keys.d/` (the default configuration includes `keys.d/*.conf`):
|
||||
```bash
|
||||
cp /etc/bind/keys.conf /etc/easydns/keys.d/keys.conf
|
||||
chown root:easydns /etc/easydns/keys.d/keys.conf && chmod 640 /etc/easydns/keys.d/keys.conf
|
||||
```
|
||||
```
|
||||
# /etc/easydns/keys.d/keys.conf – BIND syntax, as is
|
||||
key "wildcard.h.example.com" {
|
||||
algorithm hmac-sha512;
|
||||
secret "base64-secret";
|
||||
};
|
||||
key "certbot-key" { algorithm hmac-sha256; secret "base64-secret"; };
|
||||
```
|
||||
Only `key { algorithm; secret; };` statements are read from such files (comments `#`,
|
||||
`//`, `/* */` are fine); anything else is reported with its line number. Key names are
|
||||
compared as DNS names, so `certbot-key` and `certbot-key.` are the same key.
|
||||
`check-config` warns when a key file is world-readable.
|
||||
|
||||
Clients keep working without changes, e.g. certbot:
|
||||
```ini
|
||||
# /etc/letsencrypt/rfc2136.ini
|
||||
dns_rfc2136_server = 192.0.2.10
|
||||
dns_rfc2136_name = certbot-key.
|
||||
dns_rfc2136_secret = base64-secret
|
||||
dns_rfc2136_algorithm = HMAC-SHA256
|
||||
```
|
||||
and `nsupdate -k /etc/bind/keys/ddns.key` (or `-y hmac-sha512:ddns.example.com:secret`).
|
||||
|
||||
Validation (`easydns check-config`) reports unknown keys, unsupported rule types, record
|
||||
types it does not know and rules whose name lies outside the zone.
|
||||
@@ -0,0 +1,28 @@
|
||||
# Recursive resolver
|
||||
|
||||
```yaml
|
||||
recursion:
|
||||
enabled: true
|
||||
allowed_clients: ["127.0.0.0/8", "::1/128", "192.168.0.0/16"]
|
||||
qname_minimization: true
|
||||
dnssec_validation: true
|
||||
resolution: { default: recursive }
|
||||
```
|
||||
|
||||
* Real iterative resolution: root hints → root → TLD → authoritative; no upstream resolver.
|
||||
* **Anti-poisoning:** random 16-bit IDs, a fresh random source port per query, connected
|
||||
UDP sockets, question matching, bailiwick filtering (answers/authority only inside the
|
||||
queried server's zone, glue only for names inside the delegating zone), referral sanity
|
||||
checks (must be a proper descendant enclosing the name), CNAME loop detection.
|
||||
* **Limits:** `max_queries` upstream queries per resolution, `max_depth` referrals,
|
||||
`max_cname_chain`, NS-address sub-resolution depth (4), `total_timeout` deadline.
|
||||
* **Server selection:** EWMA RTT, unresponsive/lame servers are backed off.
|
||||
* **QNAME minimisation** (RFC 9156, A queries) with fallback to the full name on errors.
|
||||
* **Cache:** answers and negative answers (RFC 2308: min(SOA TTL, MINIMUM), capped by
|
||||
`max_negative_ttl`), delegations and glue with trust ranking; SERVFAIL cached 5 s.
|
||||
* **Root hints:** built in; `root_hints: file` to override; `easydns root-hints update`
|
||||
downloads the IANA file, validates it (13 servers) and replaces it atomically.
|
||||
* **Access:** recursion only for `allowed_clients` (default loopback). Other clients get
|
||||
REFUSED for non-local names; local zones remain visible to them.
|
||||
* **Offline testing:** set `authority_port` and point `root_hints` at local test servers
|
||||
(this is how the integration tests run a root→TLD→authoritative chain on 127.0.0.x).
|
||||
@@ -0,0 +1,34 @@
|
||||
# Secondary (slave)
|
||||
|
||||
```yaml
|
||||
zones:
|
||||
- name: example.net
|
||||
type: secondary
|
||||
primaries: ["192.168.1.10:53", "192.168.1.11:53"] # tried in order
|
||||
allow_notify: ["192.168.1.10/32"] # default: the primaries' addresses
|
||||
transfer: { prefer: ixfr, fallback_axfr: true, timeout: 120s, max_records: 2000000 }
|
||||
# optional TSIG: add `tsig_key: xfr-key` to `transfer:` (see zone-transfer-variants.md)
|
||||
file: null # snapshot path, default <data_dir>/zones/secondary/<zone>.zone
|
||||
```
|
||||
|
||||
Life cycle:
|
||||
1. **Startup:** the last persisted snapshot is loaded. It is served only if the last
|
||||
successful refresh (from `.meta.json`) is within SOA EXPIRE.
|
||||
2. **Refresh:** SOA query (TSIG) to the primaries; if the primary serial is RFC 1982-newer,
|
||||
IXFR (or AXFR when no local copy); IXFR failure falls back to AXFR when enabled.
|
||||
3. **Validation:** the stream must be framed by identical SOAs; IXFR differences must start
|
||||
at the local serial and end at the announced serial; the resulting zone is fully
|
||||
validated. Only then is it swapped in atomically and persisted (tmp+fsync+rename).
|
||||
An incomplete or invalid transfer never replaces the valid copy.
|
||||
4. **Timers:** success → next refresh after REFRESH; failure → after RETRY;
|
||||
no success within EXPIRE → the zone is **expired**: queries get SERVFAIL (never stale
|
||||
authoritative data) until a refresh succeeds.
|
||||
5. **NOTIFY** from allowed sources (or signed with the zone's TSIG key) triggers an
|
||||
immediate refresh. `easydns zones sync <zone>` / `POST /api/v1/zones/{zone}/sync` too.
|
||||
|
||||
Status (serial, source, last/next refresh, expiry, last error):
|
||||
`easydns zones show <zone>`, `GET /api/v1/zones/{zone}`, metrics `dns_zone_serial`,
|
||||
`dns_zone_expired`, `dns_zone_last_sync_timestamp_seconds`.
|
||||
|
||||
A secondary answers authoritatively (AA) from its own copy; it never proxies queries to
|
||||
the primary. A secondary can itself NOTIFY further secondaries (`notify:`).
|
||||
@@ -0,0 +1,119 @@
|
||||
# Encrypted DNS: DNS-over-TLS and DNS-over-HTTPS
|
||||
|
||||
EasyDNS speaks encrypted DNS in both directions:
|
||||
|
||||
| Direction | DNS-over-TLS (RFC 7858) | DNS-over-HTTPS (RFC 8484) |
|
||||
|---|---|---|
|
||||
| **Server** – your clients → EasyDNS | port 853, ALPN `dot`, many queries per connection (RFC 7766) | GET and POST on `/dns-query`, **HTTP/2** (multiplexed) and HTTP/1.1 (keep-alive), ALPN `h2`, `http/1.1` |
|
||||
| **Client** – EasyDNS → upstream resolvers | pool of persistent connections per upstream | one persistent **HTTP/2** connection per upstream carrying all concurrent queries; HTTP/1.1 fallback |
|
||||
|
||||
TLS is rustls (TLS 1.2/1.3, no legacy ciphers). Server certificates are reloaded
|
||||
automatically within 60 s after the files change (Let's Encrypt renewals need no
|
||||
restart; a broken new pair is rejected and the old certificate stays in use).
|
||||
|
||||
## 1. Secure DNS server for your network (DoT + DoH)
|
||||
|
||||
```yaml
|
||||
# /etc/easydns/config.yaml (additions to the default hybrid configuration)
|
||||
tls:
|
||||
cert_file: /etc/letsencrypt/live/dns.example.com/fullchain.pem
|
||||
key_file: /etc/letsencrypt/live/dns.example.com/privkey.pem
|
||||
dot_listen: ["0.0.0.0:853", "[::]:853"]
|
||||
doh_listen: ["0.0.0.0:443", "[::]:443"]
|
||||
recursion:
|
||||
allowed_clients: ["acl:lan", "::1/128"] # who may resolve Internet names (also over DoT/DoH)
|
||||
```
|
||||
|
||||
* The certificate must contain the name clients use (`dns.example.com`); IP-only
|
||||
certificates work for clients that support them.
|
||||
* The `easydns` user needs read access to the key:
|
||||
`setfacl -m u:easydns:rx /etc/letsencrypt/{live,archive}` and
|
||||
`setfacl -m u:easydns:r /etc/letsencrypt/archive/dns.example.com/privkey*.pem`
|
||||
(or a certbot deploy hook that copies the pair to `/etc/easydns/tls/` with mode 0640
|
||||
root:easydns).
|
||||
* DoT/DoH clients go through the same policies as UDP/TCP: recursion ACL, rate limiting,
|
||||
block lists, views. Authoritative zones are answered for everyone.
|
||||
* Serving recursion over DoT/DoH to the whole Internet makes an open resolver; keep
|
||||
`allowed_clients` to your networks (VPN users included) unless you really run a public
|
||||
resolver.
|
||||
* Behind a reverse proxy that terminates TLS (nginx, HAProxy, Caddy), use
|
||||
`doh_plaintext_behind_proxy: true` and `doh_listen: ["127.0.0.1:8053"]`; HTTP/1.1 and
|
||||
HTTP/2 cleartext (h2c, prior knowledge) are accepted. Note that ACLs then see the
|
||||
proxy's address.
|
||||
|
||||
Limits per connection: 100 concurrent HTTP/2 streams, 64 KiB body, 8 KiB headers,
|
||||
10 s to receive a request body, `server.tcp_idle_timeout` (minimum 30 s for DoH) for idle
|
||||
connections, `server.max_tcp_connections` connections in total.
|
||||
|
||||
### Client configuration
|
||||
|
||||
| Client | Setting |
|
||||
|---|---|
|
||||
| Android 9+ | Settings → Network → Private DNS → `dns.example.com` (DoT) |
|
||||
| Firefox | Settings → Privacy → DNS over HTTPS → Custom: `https://dns.example.com/dns-query` |
|
||||
| Chrome / Edge | Settings → Privacy and security → Use secure DNS → Custom: `https://dns.example.com/dns-query` |
|
||||
| Windows 11 | Settings → Network → DNS server assignment → DNS over HTTPS: Manual template `https://dns.example.com/dns-query` |
|
||||
| systemd-resolved | `DNS=192.0.2.53#dns.example.com` and `DNSOverTLS=yes` in `/etc/systemd/resolved.conf` |
|
||||
| iOS / macOS | a configuration profile with `DNSSettings` (`DNSProtocol` HTTPS or TLS, `ServerURL` / `ServerName`) |
|
||||
| Another EasyDNS | `upstreams.servers: ["tls://192.0.2.53#dns.example.com"]` |
|
||||
|
||||
### Checking it
|
||||
|
||||
```bash
|
||||
edot 192.0.2.53 example.com --tls-name dns.example.com # DoT, prints TLS version, ALPN, timings
|
||||
edoh https://192.0.2.53/dns-query example.com --tls-name dns.example.com --http2 # DoH over HTTP/2
|
||||
edoh https://192.0.2.53/dns-query example.com --tls-name dns.example.com --method get
|
||||
```
|
||||
`--ca file.pem` trusts a private CA, `--insecure` skips verification (diagnostics only).
|
||||
|
||||
## 2. Secure forwarder (encrypted upstreams)
|
||||
|
||||
Forward everything over DoT (nobody on the path – ISP, hotel Wi-Fi – sees or changes
|
||||
your queries):
|
||||
|
||||
```yaml
|
||||
resolution: { default: forward }
|
||||
upstreams:
|
||||
strategy: fastest # or failover / round-robin
|
||||
timeout: 2s
|
||||
servers:
|
||||
- "tls://1.1.1.1:853#cloudflare-dns.com"
|
||||
- "tls://9.9.9.9:853#dns.quad9.net"
|
||||
- "https://[2606:4700:4700::1111]/dns-query#cloudflare-dns.com"
|
||||
```
|
||||
|
||||
* The part after `#` is the certificate name; it is verified against the built-in
|
||||
Mozilla root store. For an internal resolver with a private CA add
|
||||
`upstreams.tls_ca_file: /etc/easydns/tls/internal-ca.pem`.
|
||||
* Connections are kept open: DoT upstreams use a pool (up to 8 idle connections per
|
||||
upstream, reused for 20 s), DoH upstreams multiplex all concurrent queries over one
|
||||
HTTP/2 connection. A connection closed by the server is replaced transparently.
|
||||
* `forward_zones` can mix transports, e.g. company zones over plain DNS inside the VPN and
|
||||
everything else over DoT.
|
||||
* Combine with `recursion` for `forwardthenrecursive` (encrypted first, own recursion as
|
||||
fallback) – note that the fallback is unencrypted by nature of DNS recursion.
|
||||
* DNSSEC: forwarded answers are passed through, not validated by EasyDNS itself; the
|
||||
public resolvers above validate DNSSEC, and the encrypted channel protects their answers
|
||||
on the way to you. (Own validation applies to `recursive` resolution.)
|
||||
|
||||
Measured on loopback (2 vCPU container, release build, sequential queries):
|
||||
|
||||
| Transport | per query |
|
||||
|---|---|
|
||||
| DoT, new connection per query | 0.48 ms |
|
||||
| DoT, pooled connection | 0.06 ms |
|
||||
| DoH HTTP/1.1, new connection per query | 0.46 ms |
|
||||
| DoH HTTP/2, persistent | 0.13 ms |
|
||||
|
||||
Over a real network the saving per query is the TCP + TLS handshake, i.e. 2–3 round
|
||||
trips (e.g. 40–60 ms to a resolver 20 ms away).
|
||||
|
||||
## 3. Port overview
|
||||
|
||||
| Port | Purpose | Exposure |
|
||||
|---|---|---|
|
||||
| 53/udp+tcp | plain DNS | LAN / Internet (authoritative) |
|
||||
| 853/tcp | DoT | as needed |
|
||||
| 443/tcp | DoH | as needed |
|
||||
| 127.0.0.1:9953 | REST API / CLI | loopback only |
|
||||
| 127.0.0.1:9090 | Prometheus metrics | loopback / monitoring network |
|
||||
@@ -0,0 +1,62 @@
|
||||
# Security
|
||||
|
||||
## Defaults (secure by default)
|
||||
|
||||
| Area | Default |
|
||||
|---|---|
|
||||
| Recursion | only private LAN ranges `192.168.0.0/16`, `10.0.0.0/8` and `127.0.0.1`, `::1` (`recursion.allowed_clients`); everyone else REFUSED |
|
||||
| Zone transfers | denied unless `transfer_acl` allows (IP-based; an optional `transfer_tsig_key` adds a key check) |
|
||||
| NOTIFY | only from the zone's primaries (or a valid zone TSIG) |
|
||||
| Dynamic updates | disabled; enabled per zone by source IP (`update_acl`), key (`update_keys`) or per-record rules (`update_policy`); audited; open-to-any without a key is a validation error |
|
||||
| API | `127.0.0.1:9953`, tokens required (local control token in `data_dir`, mode 0640), admin/read-only roles, per-IP rate limit |
|
||||
| Metrics | `127.0.0.1:9090` |
|
||||
| CH TXT version.bind / id.server | REFUSED unless `server.identity` is set |
|
||||
| UDP response size | EDNS 1232 (no fragmentation), TC for larger answers |
|
||||
| Rate limit | 200 qps / client (/32, /56), burst 400, no global cap (`global_qps: 0`), RRL-style slip |
|
||||
| Listening | `0.0.0.0:53` and `[::1]:53` (default configuration); `[::]` sockets are IPv6-only |
|
||||
| DoT / DoH | off until `tls.*_listen` is set; TLS 1.2/1.3 only; certificates reloaded on change |
|
||||
| Key files | BIND `keys.d/*.conf` read as is; warning when world-readable; installer creates `/etc/easydns` as root:easydns 0750 |
|
||||
|
||||
Risky configurations produce validation warnings/errors: open resolver (`any`), transfers
|
||||
to any address without TSIG, unsigned dynamic updates from any address (error), IP-only
|
||||
dynamic updates (warning: source addresses can be spoofed), API on a non-loopback address
|
||||
without auth (error), inline secrets, plaintext DoH on non-loopback addresses.
|
||||
|
||||
## Hardening measures in code
|
||||
|
||||
* No `unsafe` (`#![forbid(unsafe_code)]` workspace-wide); clippy warns on `unwrap`/`expect`;
|
||||
untrusted input paths return errors instead of panicking. A robustness test sends
|
||||
30 000 random/mutated packets through the handler; fuzz targets exist for the parser,
|
||||
zone files, configuration and transfers.
|
||||
* Packets claiming to be responses are dropped (reflection loops); FORMERR is generated
|
||||
only for queries whose header is readable.
|
||||
* Resource limits: UDP in-flight queries (`max_inflight`), TCP connections, idle timeouts,
|
||||
pipelined queries per connection, transfer size/record limits, regex size limits,
|
||||
zone file size limit, HTTP header/body limits, resolver budgets.
|
||||
* UDP sockets use SO_REUSEPORT (`server.udp_sockets`). On Linux only processes running
|
||||
under the same effective UID can join the socket group, so run EasyDNS under its own
|
||||
dedicated user (as the systemd unit does) – another process of that user could
|
||||
otherwise bind the same port and receive part of the queries. Set `udp_sockets: 1` to
|
||||
disable SO_REUSEPORT.
|
||||
* Rate limiting: per-client buckets are on by default; the server-wide cap
|
||||
(`rate_limit.global_qps`) is off by default (0) because it drops legitimate and
|
||||
attack traffic alike – set it only if you need a hard ceiling.
|
||||
* Identical concurrent questions are coalesced into one upstream resolution, which
|
||||
reduces the number of outstanding queries a spoofing ("birthday") attack can race.
|
||||
* TSIG: HMAC-SHA256/384/512 (MD5 rejected), constant-time MAC check, fudge window,
|
||||
every message of a transfer verified (RFC 8945 §5.3.1 unsigned intermediate rule).
|
||||
* Secrets: references (`env:`, `file:`), redacted in `Debug`, never logged. Key files are
|
||||
created with mode 0600 in 0700 directories.
|
||||
* API tokens are compared by SHA-256 in constant time; tokens can be configured as hashes.
|
||||
* Logging privacy: query logs are off by default; when on, client IPs are truncated
|
||||
(/24, /48) unless `anonymize_clients: false`. Metrics have no per-domain/IP labels.
|
||||
|
||||
## Running unprivileged
|
||||
|
||||
Use the systemd unit (`User=easydns`, `AmbientCapabilities=CAP_NET_BIND_SERVICE`,
|
||||
`ProtectSystem=strict`, syscall filter, no new privileges) or the Docker image (non-root,
|
||||
`cap_drop: ALL` + `NET_BIND_SERVICE`, read-only root). `easydns run` warns when started as root.
|
||||
|
||||
## Dependencies
|
||||
|
||||
`cargo deny check` (CI) audits advisories and licenses (`deny.toml`).
|
||||
@@ -0,0 +1,65 @@
|
||||
# Specification 1.0 compliance – what is missing (0.1.0 + Unreleased changes, updated 2026-11-22)
|
||||
|
||||
Legend: ❌ missing, ⚠️ partial, 🧪 implemented but not verified by running it.
|
||||
Everything not listed here is implemented and covered by tests (see `docs/testing.md`).
|
||||
|
||||
## Features
|
||||
|
||||
| § | Requirement | Status | Details |
|
||||
|---|---|---|---|
|
||||
| 3.1 | multiple listeners with socket re-use, socket limits | ✅ | UDP socket group per address with SO_REUSEPORT (`server.udp_sockets`); one TCP listener per address |
|
||||
| 3.2 | DNAME | ❌ | not supported by the zone parser or the resolver |
|
||||
| 3.2 | RFC 3597 | ✅ | in zone files and on the wire |
|
||||
| 4 | DNSSEC on the primary | ⚠️ | online signing with NSEC; **no NSEC3 signing**; manual key rollover (add/remove key file + reload); no automated KSK/ZSK rollover schedule, no CDS/CDNSKEY |
|
||||
| 4 | `$GENERATE` in zone files | ❌ | expand beforehand (`named-compilezone`) |
|
||||
| 5 | secondary forwarding UPDATE to the primary | ❌ | a secondary answers NOTIMP to UPDATE |
|
||||
| 6 | DNSSEC: automated trust anchor updates (RFC 5011) | ❌ | built-in anchors (KSK-2017, KSK-2024) or a file; updates are manual |
|
||||
| 6 | DNSSEC: Ed448 | ❌ | zones signed only with Ed448 validate as *insecure* |
|
||||
| 6 | coalescing of identical in-flight queries | ✅ | client questions are coalesced per route (forwarder pool / recursion); internal resolver lookups are not |
|
||||
| 7 | conditional forwarding per record type | ❌ | per domain/suffix and per client only |
|
||||
| 9 | persistent cache across restarts (optional) | ❌ | |
|
||||
| 9 | separate cache for DNSSEC results | ⚠️ | validated answers use a separate cache key (`dnssec=true`); the validator's zone key cache has a fixed 300 s TTL |
|
||||
| 10 | block list update schedule | ⚠️ | `easydns blocklists update` + systemd timer; no in-process scheduler |
|
||||
| 10 | rules by record type | ❌ | blocking works by name and client, not by type |
|
||||
| 10 | per-client/per-subnet policies | ⚠️ | exemptions (`exempt_clients`) and views for zones; no different block lists per subnet |
|
||||
| 10 | RPZ | ❌ | not explicitly required; conversion is described in `migration-from-bind.md` |
|
||||
| 11.2 | DoH over HTTP/2 | ✅ | server: HTTP/2 + HTTP/1.1 (ALPN), h2c behind a proxy; client: persistent multiplexed HTTP/2 with HTTP/1.1 fallback; DoT client pooled |
|
||||
| 11.3 | DoQ / DoH3 | ❌ (as specified) | architecture prepared, not implemented |
|
||||
| 12 | response rate limiting (RRL) | ⚠️ | per client (/32, /56) + global with "slip"; no RRL per (qname, response) |
|
||||
| 12 | memory control | ⚠️ | limits on cache entries, connections, in-flight queries and sizes; no hard RSS limit |
|
||||
| 12 | API auth: token revocation/rotation | ⚠️ | via configuration change + reload; no endpoint; no JWT/mTLS (optional) |
|
||||
| 12 | hiding domain names in logs | ⚠️ | client IPs are anonymised; names in the query log are not masked (the query log is off by default) |
|
||||
| 13 | modular configuration (include) | ✅ | `include: ["zones.d/*.yaml"]` – zones, keys, ACLs, forward zones in separate files (nesting, globs) |
|
||||
| 13 | hot reload of listeners / TLS / cache size | ⚠️ | need a restart – reported in `restart_required` |
|
||||
| 14 | users with roles | ⚠️ | tokens with admin/read-only roles; no user accounts |
|
||||
| 14 | `/api/...` aliases | – | intentionally only `/api/v1` |
|
||||
| 15 | web panel | ❌ (by decision) | out of scope for the first versions; no `web/` directory |
|
||||
| 16 | Grafana dashboard export | ✅ | `deploy/grafana/easydns.json` (not tested in Grafana 🧪) |
|
||||
| 17 | CLI name | ✅ | `easydns` (short `edns`) instead of `mydns` – changed on request |
|
||||
| 17 | `easydns` over a secure socket | ⚠️ | HTTP API on loopback only; no UNIX socket |
|
||||
| 18 | man pages and completions for the `e*` tools | ⚠️ | man page + completions only for `easydns`; the tools have `--help` |
|
||||
| 18.1 | `ed`: `ixfr=SERIAL` syntax, several queries per invocation, `+multiline` | ❌ | `+multiline` is accepted and ignored |
|
||||
| 18.3 | full nslookup compatibility in `ens` | ⚠️ | the most common arguments and interactive commands |
|
||||
| 18.10 | install via Cargo, `.deb`, `.rpm`, archives | 🧪 | `cargo install --path crates/dns-cli` works; `.deb` – `scripts/build-deb.sh` (Docker) **not run** in this environment; `.rpm` – nfpm configuration only |
|
||||
| 19 | `web/`, `benches/`, `tests/` at the repository root | ⚠️ | tests live in `crates/*/tests`, benchmarking is `easybench` + `docs/testing.md`; `benches/` has only a README |
|
||||
| – | message translations (i18n) | ❌ | messages are English only |
|
||||
|
||||
## Verification (what has NOT been run)
|
||||
|
||||
| § | Requirement | Status |
|
||||
|---|---|---|
|
||||
| 20.4 | comparison with real `dig`/`host`/`nslookup` | 🧪 `scripts/e2e.sh` is ready but **has not been run** (no `dig` in the build environment); the `e*` tools are covered by their own integration tests |
|
||||
| Stage B | "external test secondary" (e.g. BIND) | ❌ interoperability with BIND as secondary/primary has not been tested; primary↔secondary was tested between EasyDNS instances (in one test process; the two-process variant is in `e2e.sh`) |
|
||||
| 20.5 | cargo-fuzz | 🧪 targets in `fuzz/`, not run; the stable robustness test (30 000 packets) runs with every `cargo test` |
|
||||
| 20.6 | 10k/50k/100k QPS, long-running test (leaks, tasks, descriptors) | ⚠️ ~54.6k QPS measured for authoritative answers on 2 vCPU; no 100k+ and no soak test; estimates vs BIND in `docs/performance.md` (estimated to stop scaling above ~4–8 cores) |
|
||||
| 20.7 | CI, ARM64, musl | 🧪 workflow ready (`ci/github-actions-ci.yml` – copy it to `.github/workflows/`), not run; ARM64/musl/macOS/Windows builds not executed |
|
||||
| 21 | Docker image, compose, systemd | 🧪 files ready, not built or run |
|
||||
| 11 | DoT/DoH upstreams in the forwarder | ✅ tested end to end (`secure_forwarder_over_dot_and_doh`): plain-DNS client → forwarder → DoT / DoH upstream with a private CA |
|
||||
| 18.9 | `ewhois` (RDAP/WHOIS) | 🧪 needs the Internet, untested |
|
||||
| 6 | DNSSEC validation on the real Internet | 🧪 tested against a local signed root→TLD→zone chain; not checked with the real IANA anchors (no network in the test environment) |
|
||||
| 6 | NSEC3 validation | ⚠️ logic + RFC 5155 test vector unit-tested; no end-to-end test with an NSEC3 zone |
|
||||
|
||||
## Repository
|
||||
|
||||
* No git repository has been initialised on disk (no commits were made – commits only on request).
|
||||
* `.github/` could not be written remotely – the workflow is in `ci/github-actions-ci.yml`.
|
||||
@@ -0,0 +1,51 @@
|
||||
# Tests and results
|
||||
|
||||
All results below were produced by actually running the commands (2026-11-21, Rust 1.97.0,
|
||||
Linux x86_64 container with 2 vCPUs).
|
||||
|
||||
## Acceptance commands
|
||||
|
||||
| Command | Result |
|
||||
|---|---|
|
||||
| `cargo fmt --all -- --check` | pass |
|
||||
| `cargo clippy --workspace --all-targets --all-features -- -D warnings` | pass (0 warnings) |
|
||||
| `cargo test --workspace --all-features` | pass – see counts below |
|
||||
| `cargo build --workspace --release` | pass |
|
||||
| `./dev.sh e2e` (real `dig`/`host`/`nslookup`, two processes) | **not run yet** – `dig` was not available in the build environment |
|
||||
|
||||
## Test inventory
|
||||
|
||||
| Suite | What it covers |
|
||||
|---|---|
|
||||
| `dns-core` unit (20) | RFC 1982 serials + strategies, IDN names, zone file parse/emit incl. DNSKEY/RRSIG/NSEC/NSEC3/NSEC3PARAM/RFC 3597 round trip, TSIG request/response + multi-message chain with unsigned intermediates, UDP truncation, FORMERR, DNSSEC sign/verify/DS/tamper/expiry, NSEC logic, NSEC3 hash (RFC 5155 vector), HTTP parsing |
|
||||
| `dns-config` unit (15) | sample config, unknown-field error with line, error paths, ENV/CLI precedence, open-resolver warning, upstream syntax, durations, includes, **BIND key files** (comments, multi-line secrets, errors with line numbers), **`update_policy`** rules (BIND strings and mappings, invalid rules), zone paths with `..` before the data directory exists |
|
||||
| `dns-cli` unit (4) | **`zone create`**: zone with glue from `--ip`, external + in-zone name servers, mailbox escaping, missing glue error, files written + loaded by the config, no overwrite without `--force` |
|
||||
| `dns-server` unit (7) | query coalescing (50 identical → 1 resolution, cancelled leader releases waiters), **TLS certificate reload** (new pair picked up, broken pair rejected), **encoded-answer cache** (ID/0x20 case/TTL patching, profile/DO/name separation, generation and age invalidation, TTL 0 not cached, only plain queries – no TSIG, opcodes or trailing data, bounded memory) |
|
||||
| `dns-authoritative` unit (12) | lookup: positive/additional/case, NODATA/NXDOMAIN/ENT, CNAME chains + loops, wildcards, delegation/glue/DS at cut, validation errors, diff/apply, lint, journal chain/persistence/gap, AXFR chunking/framing, IXFR incremental/up-to-date/fallback/wrong base, zone signing (every RRset verifies, no glue/delegation signatures, NSEC chain) |
|
||||
| `dns-cache` (7), `dns-policy` (5), `dns-forwarder` (2), `dns-recursive` (1), `dns-metrics` (1), `dns-tools` (3) | TTL clamp, negative caching, LRU/eviction, rank, namespaces; rules (exact/suffix/wildcard/regex/hosts), allow > block, rate limit + slip + /56, local-only, views; strategies, circuit breaker, failover; root hints; Prometheus output; dig argument parsing |
|
||||
| `dns-server/tests/authoritative.rs` (6) | AA answers, negative TTL, wildcard, referral, MX additional, REFUSED, TCP, FORMERR; AXFR requires TSIG+ACL, wrong key → NOTAUTH, AXFR over UDP refused; **primary + secondary**: initial AXFR, change → NOTIFY → **IXFR**, unauthorised NOTIFY refused, restart of the secondary with the primary down serves the persisted copy; **EXPIRE → SERVFAIL**; **DDNS** unsigned refused, signed applied, prerequisites (YXDOMAIN), RRset delete, audit; **`update_policy`** with keys from an included BIND key file (granted name/type, wrong type/name/key/unsigned refused, wildcard strictly below), **IP-only updates** (`allow_update`) |
|
||||
| `dns-server/tests/resolver.rs` (3) | **iterative resolution from a local root → TLD → authoritative fixture** (no Internet): A, cross-zone CNAME, glueless NS, QNAME minimisation over ENTs, NXDOMAIN/NODATA with SOA, non-existent TLD, cache hit without upstream queries, TCP, REFUSED for a client outside the ACL with **no upstream query**, local-only names never sent out; **hybrid** node: primary + secondary + forward zone + recursion + block list with **no leak** of private names to the root; **forwarder failover**, hot reload, invalid reload rolled back |
|
||||
| `dns-server/tests/dnssec.rs` (2) | signed root/TLD/zone fixture: RRSIG with DO only, NSEC proofs; validating resolver: **secure** A (AD), secure CNAME chain, validated NXDOMAIN and NODATA, wildcard proof, **insecure** delegation (no AD), **bogus** → SERVFAIL, CD=1 returns data; signed zone change re-signs, source stays unsigned, restart reuses signatures |
|
||||
| `dns-server/tests/transport.rs` (3 + 1 manual) | DoT query, 20 concurrent DoT connections, untrusted CA and wrong name rejected; DoH POST/GET, 404/405/400/415/413 (no hanging connection); **DoH over HTTP/2** – 50 concurrent GET/POST multiplexed, h2 negotiated; **pooled DoT** reuse; **secure forwarder** plain DNS → DoT/DoH upstream with private CA; manual `measure_pooled_vs_one_shot` |
|
||||
| `dns-server/tests/performance.rs` (3) | coalescing of 40 identical cache misses into 1 upstream query, SO_REUSEPORT group on one port answering, **answer cache**: hit with other letter case echoes the client's spelling, DDNS change visible immediately, UDP answer stays truncated while TCP is complete, reload invalidates |
|
||||
| `dns-server/tests/robustness.rs` (1) | 30 000 random + mutated packets through the handler (UDP and TCP paths), random zone/config text – no panic, no hang, server still answers |
|
||||
| `dns-api/tests/api.rs` (1) | 401/403 roles, record add with ETag, If-Match 412, update, validation 400, filtering/pagination, zone create/delete (409 for config zones), reload, cache flush, stats, audit, OpenAPI |
|
||||
| `dns-tools/tests/cli.rs` (1) | `ed` normal/+short/--json/NXDOMAIN/AXFR, `eh`, `ens`, `eptr --json`, `ezone` ok + broken zone exit 1, `econf`, `ediff`, usage error exit 1, timeout exit 9 |
|
||||
|
||||
## Load (indicative)
|
||||
|
||||
`ebench 127.0.0.1:5353 -n www.example.com --qps 0 --duration 10s -c 50` against
|
||||
`easydns` (release) on the same 2-vCPU container (generator and server share the CPUs):
|
||||
|
||||
| Scenario | QPS | Lost | p50 | p95 | p99 | RSS |
|
||||
|---|---|---|---|---|---|---|
|
||||
| authoritative A over UDP, unthrottled, 50 workers | 54 595 | 0 % | 0.87 ms | 1.43 ms | 1.89 ms | 13 MB |
|
||||
| fixed 1 000 QPS, 20 workers | 1 000 | 0 % | 0.53 ms | 0.74 ms | 0.90 ms | |
|
||||
|
||||
After the SO_REUSEPORT/sharding changes (Unreleased), same setup: 59 400 – 60 100 QPS,
|
||||
p99 1.74 – 1.76 ms, RSS 12.3 MB (two UDP sockets on 2 vCPUs); see docs/performance.md.
|
||||
`tests/performance.rs` checks that a burst of 40 identical cache misses costs one
|
||||
upstream query and that every socket of the UDP group answers.
|
||||
|
||||
10k/50k QPS targets are reached for authoritative traffic on this hardware; 100k+ and
|
||||
long-running soak tests (leaks, task/FD growth) have not been run yet – see KNOWN_ISSUES.md.
|
||||
@@ -0,0 +1,19 @@
|
||||
# Troubleshooting
|
||||
|
||||
| Symptom | Check |
|
||||
|---|---|
|
||||
| `bind UDP ...: Address family not supported` | host without IPv6: remove `[::]` listeners (`EASYDNS_LISTEN=0.0.0.0:53`) |
|
||||
| `Permission denied` on port 53 | run with `CAP_NET_BIND_SERVICE` (systemd unit / Docker image) |
|
||||
| REFUSED for external names | client not in `recursion.allowed_clients` or `resolution.default: refuse` |
|
||||
| REFUSED for AXFR | `transfer_acl` / `transfer_tsig_key`; `dns_xfr_out_refused_total` |
|
||||
| NOTAUTH | TSIG key name/secret/algorithm mismatch or clocks differ > 300 s |
|
||||
| Secondary SERVFAIL | zone expired: `easydns zones show ZONE` → `last_error`; check primary reachability |
|
||||
| "serial is not newer" on reload | increment the SOA serial of the edited zone file |
|
||||
| SERVFAIL with DNSSEC on | `ednssec NAME TYPE` shows the failing link; with `+cd` the data is returned unvalidated |
|
||||
| `trust anchors: ...` at startup | the `recursion.trust_anchors` file must contain DS or DNSKEY records |
|
||||
| API 401/403 | token reference (`env:`/`file:`/`sha256:`), role, `api.allowed_clients` |
|
||||
| changes not applied after reload | see `restart_required` in the reload report |
|
||||
|
||||
Useful commands: `easydns check-config`, `econf check`, `ezone check`, `etrace NAME`,
|
||||
`ed @server NAME +norecurse`, `ediff NAME @a @b`, `curl localhost:9090/metrics`,
|
||||
`EASYDNS_LOG=debug easydns run ...`.
|
||||
@@ -0,0 +1,240 @@
|
||||
# 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/example.com.zone # = /etc/easydns/data/zones/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/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/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/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/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/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).
|
||||
Reference in new issue
Block a user