NSD
Authoritative DNS server for your own zones, as a primary or a secondary.
jailops app install nsdAdd --dry-run to see every step first. From the console: open Apps, pick NSD and press Install; the dialog takes the jail name, the network and the storage, and Preview steps shows the plan before anything runs. See the console.
About
NSD is an authoritative-only DNS server: it answers for the zones it is given and does no recursion. It serves zone files, sends NOTIFY and provides zone transfers to secondaries, and as a secondary requests the zones from a primary.
This definition writes a starter configuration with one example zone, example.com, under /var/db/nsd/zones, checks it with nsd-checkconf and nsd-checkzone and starts the server on port 53, UDP and TCP. Replace the example with your zones; the notes show the lines for a primary and for a secondary.
What you get
Ports
53/udpdns exposeDNS queries over UDP.53/tcpdns-tcp exposeDNS over TCP, large answers and zone transfers.
Data on its own datasets
/var/db/nsdvolumevar-db-nsdZone files (zones/), transferred zones and the state of the transfer daemon.
Configuration
/usr/local/etc/nsd/nsd.confServer and zone settings; check with nsd-checkconf before a restart. Restart:service nsd restart.
Logs
/var/log/daemon.logNSD logs to syslog (facility daemon) unless logfile is set.
Health check
TCP: port 53 accepts a connection, retried for up to 30 seconds.
Services
nsd: enabled and started
Setup, once, before the first start
Six commands, run in the jail as argv, without a shell:
/bin/mkdir -p /var/db/nsd/zones /var/run/nsd/bin/sh -c "f=/usr/local/etc/nsd/nsd.conf; grep -q 'Starter configura…/bin/sh -c "f=/usr/local/etc/nsd/nsd.conf; grep -q 'Starter configuration of the nsd app' $f 2>/dev/null || printf '%s\\n' '# Starter configuration of the nsd app; see its notes.' 'server:' ' username: nsd' ' database: \"\"' ' zonesdir: \"/var/db/nsd/zones\"' ' zonelistfile: \"/var/db/nsd/zone.list\"' ' xfrdfile: \"/var/db/nsd/xfrd.state\"' ' xfrdir: \"/var/db/nsd\"' ' hide-version: yes' '' 'remote-control:' ' control-enable: no' '' 'zone:' ' name: \"example.com\"' ' zonefile: \"example.com.zone\"' > $f"/bin/sh -c "f=/var/db/nsd/zones/example.com.zone; [ -e $f ] || printf…/bin/sh -c "f=/var/db/nsd/zones/example.com.zone; [ -e $f ] || printf '%s\\n' '$ORIGIN example.com.' '$TTL 3600' '@ IN SOA ns1.example.com. hostmaster.example.com. ( 2026103001 3600 900 1209600 300 )' '@ IN NS ns1.example.com.' 'ns1 IN A 192.0.2.53' 'www IN A 192.0.2.80' > $f"/usr/sbin/chown -R nsd:nsd /var/db/nsd /var/run/nsd/usr/local/sbin/nsd-checkconf /usr/local/etc/nsd/nsd.conf/usr/local/sbin/nsd-checkzone example.com /var/db/nsd/zones/example.com.zone
After the installation
The notes of the definition, shown after the installation too.
The server answers for example.com from /var/db/nsd/zones/example.com.zone. Put your zone files there, name each in a zone: block of /usr/local/etc/nsd/nsd.conf, run nsd-checkconf /usr/local/etc/nsd/nsd.conf and service nsd restart. Raise the SOA serial with every change.
Primary (this jail 192.0.2.53, the secondary 198.51.100.53), in the zone: block:
notify: 198.51.100.53 NOKEY
provide-xfr: 198.51.100.53 NOKEYSecondary (the primary 192.0.2.53), in the zone: block, after deleting the starter zone file (the transfer writes it):
allow-notify: 192.0.2.53 NOKEY
request-xfr: 192.0.2.53 NOKEYUse a TSIG key instead of NOKEY across untrusted networks: a key: block with name, algorithm hmac-sha256 and secret, the same on both sides, and its name in place of NOKEY. Delegate the zone at its parent to both servers.
How it connects
jailops app allow nsd from @web
This opens the ports 53/udp, 53/tcp of this app to the jail web, and nothing else. The service itself must listen on the jail's address and accept the client.
An installed app is closed: nothing reaches it, not even its own network, until you allow a source. A source is a jail (@web), a jail of another project (@project/web), an address set, an address or prefix, or host. jailops app access nsd lists who may connect. The names here are jail names: jailops app install names the jail after the app unless --name says otherwise.