nsd-control
Remote administration utility for NSD DNS serverSynopsis
Description
nsd-control performs remote administration on the nsd(8) DNS server. It reads the configuration file, contacts the NSD server over SSL, sends the command, and displays the result. Commands that require a reload are queued, and the result indicates the command was accepted.Options
Show the version and command-line option help.
The config file to read with settings. If not given, the default config file is used.
IPv4 or IPv6 address of the server to contact. If not given, the address is read from the config file.
Commands
Server Control
start
Start the server. Simply execs nsd(8). The NSD executable is searched at the default location relative to the installation prefix. Override by setting
NSD_PATH environment variable.stop
Stop the server. The server daemon exits gracefully.
Reload zone files and reopen log file.
- Without argument: Reads changed zone files
- With zone argument: Reads the zone file for the given zone and loads it
reconfig
Reload nsd.conf and apply changes to TSIG keys, configuration patterns, and zone additions/removals. Other changes (like listening address, port, chroot) are not applied. New patterns become available for
addzone command.repattern
Same as
reconfig.log_reopen
Reopen the log file. Useful for log rotation. Can also be triggered with
kill -HUP.status
Display server status.Exit codes:
- 0: Running
- 1: Error
- 3: Not running (connection refused)
Statistics
stats
Output statistics as name=value lines. Requires NSD to be compiled with statistics enabled. Counters are zeroed after output.
stats_noreset
Same as
stats, but does not zero the counters.Zone Management
Add a new zone to the running server. Format:
addzone <zone name> <pattern name>The zone is added to the zonelist file on disk and persists after restart. For secondary zones, zone transfer is immediately attempted. For zones with a zonefile, the file is read.Remove zone from the running server. The zone is removed from:
- Zonelist file on disk
- Memory
- nsd.db file
Change a zone to use a different pattern. Format:
changezone <zone name> <pattern name>The zone is deleted and re-added in one operation. Zones in nsd.conf cannot be changed this way.addzones
Add zones read from stdin. Input format: one line per zone with
name space patternname. For bulk additions.delzones
Remove zones read from stdin. Input format: one name per line. For bulk removals.
Zone Operations
Write zone files to disk. Writes zones that have changed (via AXFR or IXFR) or creates zonefile if it doesn’t exist. Directory components are created if necessary.
- Without argument: Write all modified zones
- With zone argument: Write that zone if modified
Send NOTIFY messages to secondary servers configured in
notify: lists for primary zones.- Without argument: Notify for all zones
- With zone argument: Notify for that zone
Attempt to update secondary zones by contacting primaries configured via
request-xfr: lists. Resets backoff timeout for zones with no content.- Without argument: Transfer all zones
- With zone argument: Transfer that zone
Force update secondary zones. Performs full AXFR even if primary has same serial number.
- Without argument: Force transfer all zones
- With zone argument: Force transfer that zone
Print zone state, serial numbers, and timestamps.States:
- primary: Primary zone
- ok: Secondary zone is up-to-date
- expired: Secondary zone has expired
- refreshing: Secondary zone has active transfers
- served-serial: Currently active
- commit-serial: In reload
- notified-serial: Got notify, fetching data
Server Information
serverpid
Print the PID of the server process. Used for statistics (only works when NSD is compiled with statistics enabled).Do not use this PID for sending signals; use the PID from nsd.pid instead.
Change logging verbosity level.
TSIG Key Management
Print TSIG key secret and algorithm.
- Without argument: List all TSIG keys
- With key name: Print that key
Change existing TSIG key to new secret. Format:
update_tsig <name> <secret>Secret is base64 encoded. Changes are in-memory only and lost on restart.Add new TSIG key. Format:
add_tsig <name> <secret> [algo]Default algorithm is hmac-sha256. Secret is base64 encoded. Changes are in-memory only.Associate zone with TSIG key. Format:
assoc_tsig <zone> <key_name>Adjusts ACLs for notify, allow-notify, provide-xfr, and request-xfr to use the given key.Delete TSIG key. Prints error if key is in use. Changes are in-memory only.
DNS Cookie Management
Add or replace a cookie secret persistently. Secret must be a 128-bit hex string.Cookie secrets can be active (used to create cookies) or staging (only for verification).
- First secret added becomes active
- If active secret exists, new secret becomes staging
- Add new secret as staging on all nodes
- Activate on all nodes with
activate_cookie_secret - Wait 1 hour
- Drop old secret with
drop_cookie_secret
drop_cookie_secret
Drop the staging cookie secret.
activate_cookie_secret
Make the current staging secret active, and the current active secret staging.
print_cookie_secrets
Show current cookie secrets with their status (active or staging).
Exit Code
The nsd-control program exits with:- 0: Success
- 1: Error
Setup
Remote control requires self-signed certificates and private keys for both server and client.Using nsd-control-setup
Thensd-control-setup script generates the required certificates and keys in the default run directory (or use -d for another directory).
- Generates server and client certificates
- Preserves existing private keys
- Sets proper permissions (owner and group readable only)
- Turn on
control-enable: yesin nsd.conf - Restart NSD
Statistic Counters
Thestats and stats_noreset commands show these counters:
Query Statistics
num.queries
Total queries received (tls + tcp + udp).
serverX.queries
Queries handled by server process X. Number of processes set by
server-count.num.type.X
Queries with this query type (A, AAAA, MX, etc.).
num.opcode.X
Queries with this opcode.
num.class.X
Queries with this query class.
num.rcode.X
Answers with this return code.
Transport Statistics
num.edns
Queries with EDNS OPT.
num.ednserr
Queries which failed EDNS parse.
num.udp
Queries over UDP IPv4.
num.udp6
Queries over UDP IPv6.
num.tcp
Connections over TCP IPv4.
num.tcp6
Connections over TCP IPv6.
num.tls
Connections over TLS IPv4 (not part of num.tcp).
num.tls6
Connections over TLS IPv6 (not part of num.tcp6).
Answer Statistics
num.answer_wo_aa
Answers with NOERROR rcode without AA flag (includes referrals).
num.rxerr
Queries for which receive failed.
num.txerr
Answers for which transmit failed.
num.raxfr
AXFR requests from clients (served with reply).
num.rixfr
IXFR requests from clients (served with reply).
num.truncated
Answers with TC flag set.
num.dropped
Queries dropped due to failed sanity check.
Timing Statistics
time.boot
Uptime in seconds since server started (with fractional seconds).
time.elapsed
Time since last stats report in seconds (with fractional seconds). Can be zero if polled quickly.
Size Statistics
size.db.disk
Size of nsd.db on disk in bytes.
size.db.mem
Size of DNS database in memory in bytes.
size.xfrd.mem
Memory for zone transfers and notifies in xfrd process (excludes TSIG data) in bytes.
size.config.disk
Size of zonelist file on disk (excludes nsd.conf) in bytes.
size.config.mem
Size of config data in memory (kept in both server and xfrd) in bytes.
Zone Statistics
zone.primary
Number of primary zones served (zones without
request-xfr:). Also output as zone.master.zone.secondary
Number of secondary zones served (zones with
request-xfr). Also output as zone.slave.Files
- Default config file:
/etc/nsd/nsd.conf(or compile-time default) - Certificate directory:
/etc/nsd/(or compile-time default)nsd_server.key- Server private keynsd_server.pem- Server certificatensd_control.key- Client private keynsd_control.pem- Client certificate
See Also
- nsd.conf(5) - NSD configuration file
- nsd(8) - NSD name server daemon
- nsd-checkconf(8) - Check NSD configuration