Skip to content

Commit 9484646

Browse files
committed
Keep a local copy of the OpenNIC root zone to avoid stale delegations
1 parent 981ddb5 commit 9484646

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ In OpenNIC mode:
203203

204204
- Unbound bootstraps from the OpenNIC root servers (`opennic.hints`) and never
205205
contacts the ICANN root servers, internic.net, or IANA.
206+
- Unbound keeps a local copy of the root zone, transferred from those same root
207+
servers, so delegations come from a complete zone instead of from referrals
208+
cached per query. This mirrors what the ICANN path does with the root zone
209+
from internic.net. If the transfer fails, Unbound falls back to querying the
210+
root servers directly.
206211
- DNSSEC validation is anchored to the OpenNIC root key (`opennic.key`) and
207212
kept up to date automatically (RFC 5011). The OpenNIC root also serves the
208213
DS records of the ICANN TLDs, so DNSSEC keeps working for the regular

‎unbound.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ server:
147147
root-hints: "opennic.hints"
148148
auto-trust-anchor-file: "var/opennic.key"
149149
EOT
150+
151+
# Keep a local copy of the root zone, like the ICANN path does. Without it
152+
# every delegation is a cached referral from whichever root server answered,
153+
# so a single server serving stale data can break a TLD until the cache
154+
# expires. Slaved from the servers already in opennic.hints, so this adds no
155+
# dependency beyond the root servers Unbound is configured to use.
156+
opennic_masters=$(awk '$1 !~ /^;/ && $3 == "A" { printf " master: %s\n", $4 }' \
157+
/opt/unbound/etc/unbound/opennic.hints)
158+
if [ -n "$opennic_masters" ]; then
159+
cat >>/opt/unbound/etc/unbound/unbound.conf <<EOT
160+
161+
auth-zone:
162+
name: "."
163+
${opennic_masters}
164+
fallback-enabled: yes
165+
for-downstream: no
166+
for-upstream: yes
167+
zonefile: "var/opennic-root.zone"
168+
EOT
169+
fi
150170
else
151171
cat >>/opt/unbound/etc/unbound/unbound.conf <<EOT
152172

0 commit comments

Comments
 (0)