Debian Codegraph @

cmd/atomdns/handlers/sign/README.md

raw
1 # Name
2
3 _sign_ - add DNSSEC records to zone files
4
5 # Description
6
7 The _sign_ handler is used to sign zones. In this process DNSSEC resource records are
8 added. The signatures that sign the resource records sets have an expiration date, this means the
9 signing process must be repeated before this expiration data is reached. Otherwise the zone's data
10 will go bad (RFC 4035, Section 5.5). The _sign_ handler takes care of all of this.
11
12 _sign_ works in conjunction with the _dbfile_ handler; this handler **signs** the zone's files, and
13 _dbfile_ **serves** the zone's _data_.
14
15 For _sign_ to work at least one key is needed. This "Common Signing Key" will be used to sign the entire
16 zone, _sign_ does _not_ support the ZSK/KSK split, nor will it do key or algorithm rollovers - it just signs.
17 This is the most authentic way of doing DNSSEC as it mimics the fire-and-forget style of the DNS.
18
19 By default every record will get a TTL of 3600 seconds, but see the `ttl` option.
20
21 _sign_ will:
22
23 - (Re)-sign the zone with the CSK(s) when:
24 - The first signature found on the SOA only has 9 days left before expiring.
25 - The source zone **FILE** has been written to.
26
27 When signing it will:
28
29 - Add the DNSKEYs to the apex of the zone.
30
31 - Create RRSIGs that have an inception of -3 hours (minus a jitter between 0 and 18 hours)
32 and a expiration of +32 (plus a jitter beteen 0 and 100 hours) days for every given DNSKEY.
33
34 - Add NSEC records for all authoritative names in the zone.
35
36 - Add or replace _all_ apex CDS/CDNSKEY records with the ones derived from the given keys. For
37 each key two CDS records are created, one with SHA1 and another with SHA256.
38
39 - Update the SOA's serial number to the _unix epoch_ of when the signing happens. This will
40 overwrite _any_ previous serial number.
41
42 The state of each (signed) zone will be checked at 5 hour intervals.
43
44 Keys are named (following BIND9): `K<name>+<alg>+<id>.key` and `K<name>+<alg>+<id>.private`.
45 The keys **must not** be included in your zone; they will be added by _sign_. These keys can be
46 generated with `ldns-keygen` or BIND9's `dnssec-keygen`. You don't have to adhere to this naming
47 scheme, but then you need to name your keys explicitly, see the `keys` directive, and note that
48 `.key` and `.private` are always used as suffixes.
49
50 A generated zone is written out in a file named `<name>.signed` in the **DIRECTORY** named by the
51 `directory` directive or otherwise the directory where to original **FILE** is found.
52
53 # Syntax
54
55 ```
56 sign FILE {
57 ttl TTL
58 key KEYFILE [KEYFILE]...
59 directory DIRECTORY
60 zonemd
61 }
62 ```
63
64 - **FILE** is the input zone file to sign. If the path is relative, the path from the _root_ global handler will be prepended to it.
65 - `ttl` specifies the TTL of all records that will be signed, and for the new records (NSEC, RRSIG) that get added to the zone. Without
66 this option all records that are signed will get a TTL of 3600.
67 - `key` specifies the key(s) (there can be multiple) to sign the zone. Any metadata in these files (Activate, Publish, etc.) is
68 _ignored_. These keys must also be Key Signing Keys (KSK). The **KEYFILE** must be the root name of the keys
69 files, i.e if you have "Kmiek.nl.+013+26205.key", **KEYFILE** must be "Kmiek.nl.+013+26205". For finding the
70 keys files the same rules apply as for **FILE**.
71 - **DIRECTORY** specifies where to write the signed zone files. If not specified the directory where **FILE**
72 is found is used. If the path is relative, the global _root_ will be prepended.
73 - if `zonemd` is specified the zone will be signed and a ZONEMD record will be added afterwards.
74
75 # Examples
76
77 Sign the `example.org` zone contained in the file `db.example.org` and write the result to
78 `db.example.org.signed` to let the _dbfile_ handler pick it up and serve it. The keys used
79 are read from `Kexample.org.+013+32412.key` and `Kexample.org.+013+32412.private`.
80
81 ```txt
82 example.org {
83 sign db.example.org {
84 key Kexample.org.+013+32412
85 }
86 dbfile db.example.org.signed
87 }
88 ```
89
90 Running this leads to the following log output
91
92 ```txt
93 2025/09/15 12:00:35 INFO example.org. handlers=log,sign,dbfile
94 2025/09/15 12:00:35 INFO Start: /metrics handler=global
95 2025/09/15 12:00:35 INFO Startup: signing: db.example.org handler=sign
96 2025/09/15 12:00:35 INFO Zone "example.org." in "db.example.org" is signed and is written to db.example.org.signed handler=sign
97 2025/09/15 12:00:35 INFO Startup: reload: db.example.org.signed handler=dbfile
98 2025/09/15 12:00:47 INFO Zone "example.org." in "db.example.org" is signed and is written to db.example.org.signed handler=sign
99 2025/09/15 12:00:47 INFO Resign of zone "example.org." in "db.example.org" successful handler=sign
100 2025/09/15 12:00:49 INFO Reload of zone "example.org." in "db.example.org.signed" successful handler=dbfile
101 ```
102
103 Forcibly resigning a zone can be accomplished by removing the signed zone file (atomdns will keep
104 on serving it from memory), and `touch`-ing **FILE**.
105
106 # Metrics
107
108 If monitoring is enabled the following metrics are exported:
109
110 - `atomdns_sign_duration_seconds{zone}` - tracks how long each signing operation takes.
111 - `atomdns_sign_rrsig_expire_timestamp{zone}` - shows when the signatures are about to expire.
112
113 # See Also
114
115 The DNSSEC RFCs: RFC 4033, RFC 4034 and RFC 4035. And the best current practice (BCP) on DNSSEC, RFC 6781. And
116 the _dbfile_ handler's documentation. Useful DNS(SEC) tools can be found in
117 [ldns](https://nlnetlabs.nl/projects/ldns/about/), e.g. `ldns-key2ds` to create DS records from DNSKEYs.