How to Install NSD on Alpine Linux Latest

NSD (Name Server Daemon) is an open-source authoritative name server. Alpine Linux is a lightweight Linux distribution that is designed to be used in resource-constrained environments. In this tutorial, we will be installing NSD on Alpine Linux.

Prerequisites

Before we start installing NSD on Alpine Linux, make sure that you have the following prerequisites:

Step 1: Update the System

The first step is to update the system's package manager to the latest version using the following command:

sudo apk update

Step 2: Install NSD

NSD can be easily installed using the following command:

sudo apk add nsd

Step 3: Configure NSD

Once NSD is installed, you will need to configure it. The default configuration file is located at /etc/nsd/nsd.conf. You can edit this file using your preferred text editor.

For example, to configure NSD to serve example.com, you can add the following lines to the file:

zone:
    name: "example.com"
    zonefile: "/etc/nsd/zones/example.com.zone"

Then, create the zone file at /etc/nsd/zones/example.com.zone with the following contents:

$TTL 3600
example.com. IN SOA ns1.example.com. hostmaster.example.com. (
                    2020091601 ; serial
                    7200       ; refresh (2 hours)
                    3600       ; retry (1 hour)
                    1209600    ; expire (2 weeks)
                    3600       ; minimum (1 hour)
                    )
               IN NS ns1.example.com.
ns1            IN A  192.168.0.1
www            IN A  192.168.0.2

Make sure to replace the IP addresses with your own IP addresses.

Step 4: Start NSD

Once you have configured NSD, you can start the service using the following command:

sudo rc-service nsd start

Step 5: Test NSD

To test if NSD is running correctly, you can use the following command to query your local DNS server for the A record of example.com:

dig @127.0.0.1 example.com A

If NSD is running correctly, you should receive a response containing the IP address of example.com.

Conclusion

In this tutorial, we have successfully installed and configured NSD on Alpine Linux. NSD is now ready to provide authoritative DNS services for your domain.

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!