pr:bind-lost-keys
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Nächste Überarbeitung | Vorherige Überarbeitung | ||
| pr:bind-lost-keys [2026/04/06 17:32] – angelegt martok | pr:bind-lost-keys [2026/04/07 10:40] (aktuell) – martok | ||
|---|---|---|---|
| Zeile 3: | Zeile 3: | ||
| ===== Problem ===== | ===== Problem ===== | ||
| - | Bind has changed their DNSSEC management mechanism from `auto-dnssec maintain;` to policy-based management. This by itself does cause many headaches, but not immediate bugs. | + | BIND has changed their DNSSEC management mechanism from '' |
| - | Unless the policy chooses to generate keys for signature schemes that are not actually used, for example because one later changes the policy | + | Unless the policy chooses to generate keys for signature schemes that are not actually used, for example because one later changes the policy |
| + | |||
| + | This used to be mostly fine with '' | ||
| + | |||
| + | ===== Diagnosis ===== | ||
| + | |||
| + | This is easy: we get millions of log lines along the lines of | ||
| + | |||
| + | < | ||
| + | zone_maintenance: | ||
| + | zone_resigninc: | ||
| + | dns_zone_findkeys: | ||
| + | dns_zone_findkeys: | ||
| + | dns_zone_findkeys: | ||
| + | dns_zone_findkeys: | ||
| + | </ | ||
| + | |||
| + | ===== Recreating the missing keys ===== | ||
| + | |||
| + | First, collect the problematic keys from log file. It's going to be large, so we use tail to save some cycles - we're in a loop anyway. | ||
| + | <code bash> | ||
| + | tail -n 500000 named.log | perl -ne '/ | ||
| + | </ | ||
| + | |||
| + | Now we need to give BIND something to write its state in. But we don't have the key material anymore? | ||
| + | Turns out we do (at least the public part), in the currently RRset! So we query ourself for every domain that reports an issue and let '' | ||
| + | |||
| + | <code bash> | ||
| + | # | ||
| + | |||
| + | test -d dist || mkdir dist | ||
| + | |||
| + | while read k ; do | ||
| + | test -f ./ | ||
| + | d=${k#K} | ||
| + | d=${d%%+*} | ||
| + | |||
| + | # grab the key material and import into new files | ||
| + | dig @::1 DNSKEY $d | dnssec-importkey -f - $d > /dev/null | ||
| + | |||
| + | if [ -f $k.key ] ; then | ||
| + | # expire it | ||
| + | dnssec-settime -D now $k.key | ||
| + | |||
| + | # save for manual apply | ||
| + | chown bind:bind $k.* | ||
| + | echo Created: $k.* | ||
| + | mv $k.* ./dist/ | ||
| + | else | ||
| + | echo Not in RRset: $k | ||
| + | fi | ||
| + | |||
| + | # cleanup work dir | ||
| + | rm K$d+*.{key, | ||
| + | done < ~/ | ||
| + | </ | ||
| + | |||
| + | Now we can copy the files from '' | ||
| + | |||
| + | For each affected zone, do this: | ||
| + | <code bash> | ||
| + | d=security.fail ; rndc loadkeys $d && sleep 30 && rndc sign $d && sleep 20 && tail -n 50000 / | ||
| + | </ | ||
| + | |||
| + | Why manually instead of one big loop? Mostly because I'm a scaredy cat and want to see the results for each. It's fun to sit on a '' | ||
| + | |||
| + | Why '' | ||
| + | |||
| + | |||
| + | ===== Cleanup ===== | ||
| + | |||
| + | It's worth mentioning again: do NOT delete the key files, even after we've removed them from the zone. BIND will have taken the Deleted value we gave it, turned it into Inactive and added the usual delay to the new Deleted timer. Once that expires, the fake key files will be purged automatically. | ||
pr/bind-lost-keys.1775489549.txt.gz · Zuletzt geändert: 2026/04/06 17:32 von martok
