Configuration Overview
NSD uses a configuration file, typicallynsd.conf, to specify all server options, zone configurations, and access controls. The configuration file follows a structured format with multiple top-level sections.
Configuration File Format
The configuration file uses a simple attribute-value notation:Basic Rules
- Comments: Start with
#and extend to the end of the line - Whitespace: Empty lines and leading whitespace are ignored
- Quotes: Use quotes for values containing spaces:
"file name.zone" - Keywords: Must have whitespace between them and end with a colon
:
There must be whitespace between keywords. Attribute keywords end with a colon
:. An attribute is followed by its containing attributes or a value.Top-Level Sections
The configuration file supports seven top-level sections:| Section | Purpose |
|---|---|
server: | Global server options and settings |
zone: | Individual zone configuration |
pattern: | Reusable zone configuration templates |
key: | TSIG keys for authentication |
tls-auth: | TLS authentication for XFR-over-TLS |
remote-control: | Settings for nsd-control utility |
verify: | Zone verification options |
Example Structure
Including External Files
You can split your configuration across multiple files using theinclude: directive:
Include Features
- Can appear anywhere in the configuration
- Takes a single filename as an argument
- Supports wildcard patterns:
*,?,{},[],~(seeglob(7)) - If no files match the pattern, this is not an error
- Processed as if text was copied into the file at that point
Configuration File Validation
Before starting NSD, validate your configuration:- Check syntax errors
- Validate attribute values
- Report line numbers for any issues
- Verify zone file paths and permissions
Dynamic Zone List
NSD maintains a separate zone list file for dynamically added/removed zones:nsd-control commands:
nsd-control addzone- Add a zonensd-control delzone- Remove a zone- Zones in the main config cannot be deleted via these commands
Configuration Reloading
NSD supports multiple reload mechanisms:Signal-based Reload
nsd-control Commands
Automatic Reload
Enable automatic config reload on SIGHUP:What happens during a reload?
What happens during a reload?
During a reload:
- Modified zone files are detected via mtime checks
- New zones are loaded into memory
- Query processing continues without interruption
- Old zone data is replaced atomically
- NOTIFY messages are sent for updated primary zones
Configuration Examples
Minimal Configuration
Multi-Server Configuration
Best Practices
Organize with patterns
Organize with patterns
Use patterns to avoid duplicating configuration:
Use includes for secrets
Use includes for secrets
Store keys in a separate file with restricted permissions:
Set appropriate permissions
Set appropriate permissions
Recommended file permissions:
nsd.conf: 644 (readable by all, writable by root)- Secret key files: 600 (readable/writable by root only)
- Zone files: 644 (readable by all)
- PID file: 644 (created by NSD)
See Also
- Server Options - Detailed server configuration
- Zone Configuration - Zone-specific settings
- Patterns - Reusable configuration templates
- Access Control - ACL and security settings