NSD, or Name Server Daemon, is a versatile and efficient open-source DNS server. In this tutorial, we will go over the steps to install NSD on OpenBSD.
Before we begin, make sure that you have the following prerequisites:
Open a terminal or shell session and follow these steps to install NSD:
Update the package repository:
$ sudo pkg_add -Uu
Install NSD:
$ sudo pkg_add nsd
Confirm the installation by querying the version of NSD installed on your system:
$ nsd -v
NSD 4.3.6
Start the NSD service:
$ sudo rcctl enable nsd
$ sudo rcctl start nsd
The enable
command configures NSD to start at boot time, and the start
command starts the NSD service immediately.
Now that NSD is installed and running, let's configure it to serve DNS requests for your domain(s). Follow these steps to create a basic configuration for NSD:
Create a configuration file for NSD:
$ sudo touch /var/nsd/etc/nsd.conf
Add the following configuration to the nsd.conf
file:
server:
hide-version: yes
logfile: "/var/nsd/log/nsd.log"
zone:
name: "example.com"
zonefile: "/var/nsd/zones/example.com.zone"
This configuration tells NSD to serve DNS requests for the example.com
domain and to log its activity to /var/nsd/log/nsd.log
.
Create a zone file for your domain. For example:
$ sudo touch /var/nsd/zones/example.com.zone
Edit the zone file and add the following contents:
$ORIGIN example.com.
$TTL 86400 ; 24 hours
example.com. IN SOA ns1.example.com. admin.example.com. (
1 ; serial number
3600 ; refresh every hour
600 ; retry every 10 minutes
86400 ; expire after 1 day
3600 ) ; default TTL of 1 hour
example.com. IN NS ns1.example.com.
ns1.example.com. IN A 192.0.2.1
This configuration sets up a basic DNS zone for the example.com
domain, with a single nameserver (ns1.example.com
) and an IP address associated with it.
Reload the NSD configuration:
$ sudo rcctl reload nsd
This command reloads the NSD configuration, which incorporates the changes you made to the nsd.conf
file and the zone file.
To test if NSD is running and serving DNS requests, follow these steps:
Query NSD for the IP address of ns1.example.com
:
$ nslookup ns1.example.com localhost
Verify that the response matches the IP address you configured in your zone file.
Congratulations! You've successfully installed and configured NSD on OpenBSD.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!