How to Install NSD on NixOS Latest

NSD (Name Server Daemon) is an authoritative DNS server that is optimized for speed, performance, and security. It is an excellent alternative to BIND, and it is especially useful for serving large numbers of domains. In this tutorial, we will show you how to install NSD on NixOS Latest.

Prerequisites

Before installing NSD, make sure your system is up to date:

sudo nix-channel --update
sudo nixos-rebuild switch

Ensure you have an Internet connection.

Step 1: Install NSD

The first step to installing NSD on NixOS is to add it to your configuration.nix file.

Add the following line to your configuration.nix file:

services.nsd.enable = true;

Save and close the file.

Then, rebuild your system by running the following command:

sudo nixos-rebuild switch

This command will install NSD on your NixOS machine.

Step 2: Configure NSD

After you've installed NSD, the next step is to configure it.

Create a new configuration file for NSD by running the following command:

sudo nano /etc/nsd/nsd.conf

Add the following lines to the configuration file:

server:
    username: nsd
    hide-version: yes

## Control settings
control:
    enable: yes
    module-path: "/nix/store/8pmv0yp2fzmx0z58gjjssjkr6xyavht6-nsd-4.3.7/libexec/nsd"
    database: "/var/db/nsd/nsd.db"
    pidfile: "/run/nsd/nsd.pid"


key:
    name: "rndc-key"
    algorithm: hmac-sha256
    secret: "<use a long randomized string in here>"

You can change the "secret" field to whatever key you want, but make sure it is a long randomized string.

Save and close the configuration file.

Step 3: Start NSD

After configuring NSD, the next step is to start it.

To start NSD, run the following command:

sudo systemctl start nsd.service

This command will start NSD on your NixOS machine.

To check the status of NSD, run the following command:

sudo systemctl status nsd.service

This command will display NSD's status on your NixOS machine.

Conclusion

Now that you have installed and configured NSD on NixOS Latest, you can start using it to manage your DNS records.

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!