Installing Knot on NixOS

In this tutorial, you will learn how to install Knot DNS, a high-performance authoritative-only DNS server, on the latest version of NixOS.

Prerequisites

Before you begin, you will need the following:

Step 1: Install Knot

You can install Knot DNS by running the following command in your terminal:

sudo nix-env -i knot 

This will download and install Knot DNS on your NixOS system.

Step 2: Configure Knot

Once Knot DNS is installed, you need to configure it to use it as an authoritative-only DNS server.

  1. Create a new configuration file for Knot DNS using the following command:
sudo nano /etc/knot/knot.conf 
  1. Configure the Knot DNS server by adding the following lines to the configuration file:
server:
  listen: [::]:53
  rundir: /var/run/knot/
  storage: "/var/lib/knot/"

log:
  syslog: yes
  severity: info
  trace: no

acl:
  acl_localnets: 127.0.0.1/32 ::1/128 192.168.0.0/16

template:
  template_localnets: &template_localnets { 
    acl: acl_localnets 
  }

acl:
  acl_my-network: 192.168.100.0/24
  acl_dyn-block: !auth * * 

zone:
  - domain: "example.com"
    file: "/etc/knot/example.com.zone"
    template: *template_localnets
    acl: [ acl_my-network, acl_dyn-block ]

In the above configuration file, the acl_localnets section defines a list of IP addresses that are allowed to access the server. The template_localnets section is a named configuration that includes the acl_localnets list, and it is referenced by the zone section.

  1. Save and close the configuration file.

Step 3: Start Knot

To start the Knot DNS server, run the following command:

sudo systemctl start knot

You can then confirm that Knot DNS is running by checking its status:

sudo systemctl status knot

Conclusion

Now you know how to install Knot DNS and configure it as an authoritative-only DNS server on the latest version of NixOS. Enjoy using Knot to manage and secure DNS queries!

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!