Skip to content

Unbound does not generate root.key on boot → DNSSEC does not work #335

@newtonglez

Description

@newtonglez

I expected ddnsec to work from the moment the container was created.

The root.key file wasn't generated, so ddnsec didn't work.

I got it working as follows:

*Create unbound.log
*Create a directory to hold root.key
*Create root.key

podman exec pihole sh -c 'touch /var/log/unbound/unbound.log; mkdir -p /var/lib/unbound; unbound-anchor -a "/var/lib/unbound/root.key"

*Add the line to pi-hole.conf to use root.key

podman exec pihole sh -c 'echo " trust-anchor-file: "/var/lib/unbound/root.key"" >> /etc/unbound/unbound.conf.d/pi-hole.conf'

*Add crontab settings to update root.key periodically
podman exec -it pihole bash
crontab -e

#add these lines:
00 00 1 * * unbound-anchor -a "/var/lib/unbound/root.key" >> /var/log/unbound/anchor.log 2>&1
01 00 1 * * grep '^.\s' /var/lib/unbound/root.key | wc -l >> /var/log/unbound/anchor.log
02 00 1 * * pgrep unbound && pkill -HUP unbound

*Restart the container

And now ddnsec is working (192.168.1.65 is my pihole)

dig dnssec-failed.org @192.168.1.65

; <<>> DiG 9.20.15-2-Debian <<>> dnssec-failed.org @192.168.1.65

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 8078

;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;dnssec-failed.org. IN A

;; Query time: 760 msec
;; SERVER: 192.168.1.65#53(192.168.1.65) (UDP)
;; WHEN: Mon Nov 17 00:42:00 MST 2025
;; MSG SIZE rcvd: 46

There are a few changes, I hope you consider incorporating them into your image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions