This commit is contained in:
Mateusz Gruszczyński committed 2026-11-22 14:21:54 +01:00
commit fa432bebda
189 files changed
+26219

No files matched your search

+203
View File
@@ -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.