8.7 KiB
Primary (master)
A primary serves zones from zone files (BIND format) stored in
/etc/easydns/data/zones/primary/, sends NOTIFY to its secondaries, serves AXFR/IXFR and accepts
RFC 2136 dynamic updates when allowed.
Quick start
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/primary/example.com.zone and
/etc/easydns/zones.d/example.com.yaml (see cli-tools.md).
Zone definition
zones:
- name: example.com
type: primary
file: zones/primary/example.com.zone # relative to data_dir → /etc/easydns/data/zones/primary/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.
- 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
- name: example.com
type: primary
file: zones/primary/example.com.zone
update_acl: ["198.51.100.50", "203.0.113.2"] # these hosts may change any record
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
- name: example.com
type: primary
file: zones/primary/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
TXTorA 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
(
denyrules can carve out exceptions). Unsigned updates are refused. - Not supported: Kerberos/GSS identities (
krb5-*,ms-*),tcp-self,6to4-self,external–check-configreports 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:
- name: example.com
type: primary
file: zones/primary/example.com.zone # copy of /etc/bind/example.com.conf into /etc/easydns/data/zones/primary/
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):
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:
# /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.