NSD is an open-source Domain Name System (DNS) server. It was developed by NLnet Labs of Amsterdam in cooperation with the RIPE NCC, from scratch as an authoritative name server. NSD is a NS that comes as a part of OpenBSD base.

Configuration of NSD

The main configuration file for NSD is a file called nsd.conf located in the /var/nsd/etc/ directory. Now, open/create the new file in your text editor with root privileges. Here's a sample:

	ip4-only: yes
	identity: "DNS"
	hide-version: yes
	verbosity: 1
	database: ""
	username: _nsd
	logfile: "/var/log/nsd.log"
	pidfile: "/var/nsd/run/"
	difffile: "/var/nsd/db/ixfr.db"
	xfrdfile: "/var/nsd/db/xfrd.state"
	database: "/var/nsd/db/nsd.db"

        control-enable: yes
        control-interface: /var/nsd/run/nsd.sock

	name: ""
	zonefile: "master/"
	#notify: NOKEY
	#provide-xfr: NOKEY

Primary and secondary server

If you need a secondary server to host the zone, you can do this as follows. Add to the block that describes your master zone, records about the secondary zone as in the example:

	name: ""
	zonefile: "master/"
	notify: NOKEY
	provide-xfr: NOKEY

Create a new block in the secondary server config file, as in the example:

	name: ""
	zonefile: "slave/"
	allow-notify: NOKEY
	request-xfr: NOKEY

The zone file for NSD

The next step is to write the zone files for NSD. First the forward lookup zone

; Domain file from My project    3600  SOA (
                            2020070701   ; serial YYYYMMDDnn
                            10800        ; refresh
                            3600         ; retry
                            604800       ; expire
                            86400 )      ; minimum TTL    NS    NS
ns              A    A
www             A
irc             A
imap            A
smtp            A    mx    10

Save this zone file as /var/nsd/zones/master/

Configuration check and start

NSD bring along a tool to check the configuration file before you start or reload the daemon:

$ doas nsd-checkconf /var/nsd/etc/nsd.conf

Any errors are reported, so no news are good news. You can go ahead and start NSD:

$ doas rcctl enable nsd
$ doas rcctl start nsd