Transaction Signature (TSIG) provides cryptographic authentication for DNS messages, primarily used to secure zone transfers (AXFR/IXFR) and NOTIFY messages between DNS servers.
TSIG uses shared secret keys and HMAC algorithms to sign DNS messages, ensuring that:
Messages come from an authenticated source
Messages have not been tampered with
Messages are received within an acceptable time window
From tsig.c:5, NSD implements RFC 2845 TSIG with support for multiple HMAC algorithms.
TSIG provides transaction-level security, not data-level security. For data authentication, use DNSSEC. TSIG is ideal for securing server-to-server communications.
hmac-md5 and hmac-sha1 are cryptographically weak and should only be used for compatibility with legacy systems. New deployments must use hmac-sha256 or stronger.
# Define the TSIG keykey: name: "transfer-key" algorithm: hmac-sha256 secret: "your-base64-secret-here=="# Primary zone allowing transfers with TSIGzone: name: "example.com" zonefile: "/var/nsd/zones/example.com.zone" # Allow zone transfers only with TSIG provide-xfr: 192.0.2.10 transfer-key provide-xfr: 2001:db8::10 transfer-key # Send notifies with TSIG notify: 192.0.2.10 transfer-key notify: 2001:db8::10 transfer-key
# Define the same TSIG keykey: name: "transfer-key" algorithm: hmac-sha256 secret: "your-base64-secret-here=="# Secondary zone using TSIGzone: name: "example.com" zonefile: "/var/nsd/zones/example.com.zone" # Request transfers with TSIG request-xfr: AXFR 192.0.2.1 transfer-key # Accept notifies only with TSIG allow-notify: 192.0.2.1 transfer-key
# Main nsd.conf# Include keys from separate file for securityinclude: "/etc/nsd/keys.conf"zone: name: "example.com" zonefile: "/var/nsd/zones/example.com.zone" provide-xfr: 192.0.2.10 transfer-key notify: 192.0.2.10 transfer-key
# Store keys in separate file with restricted permissionschmod 600 /etc/nsd/keys.confchown root:nsd /etc/nsd/keys.conf# Verify permissionsls -la /etc/nsd/keys.conf# Should show: -rw------- 1 root nsd
Symptom: Transfer fails with TSIG BADTIME errorCause: Clock skew between servers exceeds 300 secondsSolution:
# Check time differencedate -u; ssh remote-server date -u# Sync clocks with NTPntpdate pool.ntp.org# ortimedatectl set-ntp true
BADSIG Errors
Symptom: Transfer fails with TSIG BADSIG errorCause:
Mismatched secrets
Different algorithms
Trailing whitespace in secret
Solution:
# Verify key configuration matches on both serversnsd-checkconf /etc/nsd/nsd.conf | grep -A3 "name: transfer-key"# Generate new key and reconfigure if neededopenssl rand -base64 32
BADKEY Errors
Symptom: Transfer fails with TSIG BADKEY errorCause:
Key name mismatch
Key not defined in configuration
Case sensitivity in key name
Solution:
# List configured keysnsd-checkconf /etc/nsd/nsd.conf | grep "name:"# Ensure key name matches exactly (case-sensitive)