Default Behavior
Without specific configuration, NSD:- Binds to the default system interface
- Listens on IPv4
- Listens on IPv6 (if available)
- Uses the operating system’s routing tables for interface selection
Protocol Selection
Restrict NSD to IPv4 or IPv6 only.Command Line Options
Configuration File
Binding to Specific Interfaces
Explicitly specify which IP addresses NSD should listen on.Single Interface
Command line:Multiple Interfaces
Why Specify Interfaces?
Even if you want NSD to listen on all interfaces, explicitly configuring them provides two important benefits:1. Performance Optimization
Binding to specific interfaces bypasses the OS routing table lookup:- Small but measurable performance gain
- Reduces latency for high-volume servers
- Eliminates potential routing table errors
2. Symmetric Routing
Ensures DNS responses return through the same interface queries arrived on:- Many DNS resolvers validate that response source addresses match query destinations
- Incorrect routing can cause query failures
- OS routing tables may select the wrong interface for responses
Multi-Homed Configuration
For servers with multiple network interfaces:- Serves DNS on four different addresses
- Guarantees symmetric routing for each interface
- Avoids cross-interface routing problems
Transparent Proxy Support
Bind to non-local addresses for transparent proxy deployments.- Appropriate kernel support (Linux:
IP_TRANSPARENTsocket option) - Proper routing and firewall rules
- Elevated privileges or capabilities
Port Configuration
Change the default DNS port (53):- Testing without root privileges
- Non-standard DNS deployments
- Running multiple DNS servers on the same host
Standard DNS clients expect port 53. Only change the port for testing or specialized deployments.
Advanced Interface Options
Combine interface binding with performance tuning options:Verification
Confirm NSD is listening on the correct interfaces:Common Configurations
Single Public Interface
Public and Private Networks
Localhost Only (Testing)
All Interfaces (IPv4 and IPv6)
Troubleshooting
Address Already in Use
Error:- Check for other DNS servers using port 53:
sudo lsof -i :53 - Verify no other NSD instances are running:
ps aux | grep nsd - Ensure systemd-resolved isn’t binding to port 53
Permission Denied
Error:- Run as root or use capabilities:
sudo setcap CAP_NET_BIND_SERVICE=+ep /usr/sbin/nsd - Use a non-privileged port (>1024) for testing
- Check that the
usernameoption doesn’t drop privileges before binding
Wrong Source Address
If responses come from a different IP than expected:- Explicitly configure
ip-addressfor each interface - Consider using
bindtodevice=yes(Linux) orsetfib(FreeBSD) - Check routing tables:
ip routeorroute -n - Verify firewall rules aren’t interfering