NSD implements RFC-compliant zone expiry handling for secondary zones, ensuring that stale data is not served when primary servers become unreachable. This guide explains the technical details of zone expiry timers, state management, and recovery procedures.
zone: name: "example.com" zonefile: "/var/nsd/zones/example.com.zone" request-xfr: AXFR 192.0.2.1 NOKEY allow-notify: 192.0.2.1 NOKEY # Limit refresh to 6 hours minimum min-refresh-time: 21600 # Limit refresh to 24 hours maximum max-refresh-time: 86400
Useful for zones with unrealistic SOA refresh values.
zone: name: "example.com" zonefile: "/var/nsd/zones/example.com.zone" request-xfr: AXFR 192.0.2.1 NOKEY allow-notify: 192.0.2.1 NOKEY # Retry at least every 10 minutes min-retry-time: 600 # Retry at most every 2 hours max-retry-time: 7200
Prevents excessive retries or too-infrequent attempts.
zone: name: "example.com" zonefile: "/var/nsd/zones/example.com.zone" request-xfr: AXFR 192.0.2.1 NOKEY allow-notify: 192.0.2.1 NOKEY # Expire after at least refresh + retry + 1 second min-expire-time: refresh+retry+1 # Or use explicit time (7 days) # min-expire-time: 604800
If a secondary zone has expired and no primaries can be reached, but NSD should still serve the zone, delete the xfrd.state file, but leave the zone file intact.
1
Stop NSD
2
systemctl stop nsd
3
Important: Stop NSD first, as it writes xfrd.state on exit.
4
Delete State File
5
# Remove state filerm /var/db/nsd/xfrd.state# Keep zone files!ls -la /var/nsd/zones/
6
Start NSD
7
systemctl start nsd
8
NSD will:
9
Treat zone files as fresh/current
Serve the zones immediately
Start refresh timers from now
Still attempt to contact primaries
Use with caution: This forces NSD to serve potentially stale data. The zone will expire again after the SOA expire time unless primaries become reachable.
# Transfer zone from working primary to filedig @working-primary.example.com example.com AXFR > example.com.zone# Or use nsd-zone-copy if available# Or rsync from another secondary
3
Install Zone File
4
# Copy to NSD zones directorycp example.com.zone /var/nsd/zones/chown nsd:nsd /var/nsd/zones/example.com.zonechmod 640 /var/nsd/zones/example.com.zone
5
Reload Zone
6
# Reload specific zonensd-control reload example.com# Or reload all zonesnsd-control reload
From the documentation:
When this is done the new zone will be served. For secondary zones NSD attempts to validate the zone from the primary (checking its SOA serial number).
# View all zone statusesnsd-control zonestatus# Output includes expiry information:# zone: example.com# state: ok# served-serial: "2024030801 since 2024-03-08T10:00:00"# commit-serial: "2024030801 since 2024-03-08T10:00:00"# wait: "3461 sec between attempts"
# Single zone statusnsd-control zonestatus example.com# States can be:# - ok: Zone is current and served# - expired: Zone has expired (SERVFAIL)# - waiting: Zone is waiting for refresh
server: # Verbosity 1: Logs zone transfer failures and updates verbosity: 1 # Log to file for analysis logfile: "/var/log/nsd.log"
Log messages for expiry:
[timestamp] nsd[pid]: zone example.com: transfer failed, retry 600 sec[timestamp] nsd[pid]: zone example.com: expired, returning SERVFAIL[timestamp] nsd[pid]: zone example.com: transfer succeeded, serial 2024030802