206 lines
9.5 KiB
Markdown
206 lines
9.5 KiB
Markdown
# 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
|
||
```
|