Linode Library Home
Linode Library RSS Feed
Home :: DNS Services
Print View View Source

Provide Authoritative DNS Services with NSD on Ubuntu 9.10 (Karmic)

Published: by


This document is an older, unmaintained guide. There may be a new guide available for this software.

NSD is a lightweight yet full-featured open source name server daemon created to provide an alternative to BIND.

Before beginning, you should be familiar with basic DNS terminology and records. You will also need to ensure that your current Linode plan has enough memory to run the NSD daemon. Use the developer's memory usage calculator to determine the memory requirement for your NSD deployment.


Enable Universe Repositories

The NSD packages are included in the Ubuntu's universe repositories. Before installing NSD, edit your /etc/apt/sources.list file to enable the "universe" repositories by removing the hash symbol in front of the universe lines. The file should resemble the following example:


## main & restricted repositories
deb karmic main restricted
deb-src karmic main restricted

deb karmic-security main restricted
deb-src karmic-security main restricted

## universe repositories
deb karmic universe
deb-src karmic universe
deb karmic-updates universe
deb-src karmic-updates universe

deb karmic-security universe
deb-src karmic-security universe

When you have saved this file, issue the following command to refresh your system's package database and upgrade installed packages:

apt-get update
apt-get upgrade

Install Required Software

Ensure that your package repositories are up to date and that you've installed all available software upgrades by issuing the following commands:

apt-get update
apt-get upgrade --show-upgraded

Install NSD with the following commands:

apt-get install nsd3

You will now need to configure the daemon.

Configuring the NSD Daemon

You will need to create the nsd.conf file to properly configure the NSD service as well as the DNS zones. There is an example configuration file located in /etc/nsd3/nsd.conf that you can uncomment directives in. You may also create your own from scratch.

File excerpt:/etc/nsd3/nsd.conf

    logfile: "/var/log/nsd.log"
    username: nsd

Host Zones with NSD

You must specify at least one zone in the /etc/nsd3/nsd.conf file before NSD will begin serving DNS records. Refer to the following example configuration for proper syntax.

File excerpt:/etc/nsd3/nsd.conf

    zonefile: /etc/nsd3/

    zonefile: /etc/nsd3/

Once zones are added to the nsd.conf file, proceed to create a zone file for each DNS zone.

Creating Zone Files

Each domain has zone file specified in the nsd.conf file. The syntax of an NSD zone file is similar BIND zone files. Refer to the example zone files that follow for syntax, and modify domain names and IP addresses to reflect the needs of your deployment.

File excerpt:/etc/nsd3/

$TTL 86400

@       IN      SOA (
                                2010011801      ; serial number
                                28800           ; Refresh
                                7200            ; Retry
                                864000          ; Expire
                                86400           ; Min TTL


                MX      10

ns1     IN  A
ns2     IN  A
www             IN      A
tomato          IN      A
mail        IN  A
*               IN      A

File excerpt:/etc/nsd3/

$TTL 86400

@       IN      SOA (
                                    2009011803      ; serial number
                                    28800           ; Refresh
                                    7200            ; Retry
                                    864000          ; Expire
                                    86400           ; Min TTL


                MX      10

    ns1             IN      A
    ns2             IN      A
www             IN      A
paisano         IN      A
mail            IN      A

pizzapie    IN  CNAME   paisano

Rebuild the NSD database and restart the daemon with following command sequence:

nsdc rebuild
/etc/init.d/nsd3 restart

Rebuild the database and restart NSD each time you edit an existing zone or create a new one.

Test the configuration and functionality of the DNS serve using dig, which provides a command line DNS client. If dig is not installed, install the utility by issuing the following command:

apt-get install dnsutils

Issue the following command to test the DNS server:

dig @localhost

The output should resemble the following:

; <<>> DiG 9.6.1-P2 <<>> @localhost
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25199
;; flags: qr aa rd; QUERY: 1, ANSWER: 2, ORGNAMEITY: 2, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;  IN  A

;; ANSWER SECTION: 86400 IN  CNAME 86400  IN  A

;; ORGNAMEITY SECTION:    86400   IN  NS    86400   IN  NS

;; Query time: 18 msec

Congratulations, you have successfully installed NSD!

Adjusting NSD for Low-Memory Situations

If you are running NSD in a low-memory environment, amending the values of the following directives in your /etc/nsd3/nsd.conf file will lower your memory and system resource usage.

File excerpt:/etc/nsd3/nsd.conf

ip4-only: yes
tcp-count: 10
server-count: 1

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

Creative Commons License

This guide is licensed under a Creative Commons Attribution-NoDerivs 3.0 United States License.

Last edited by Phil Paradis on Tuesday, May 17th, 2011 (r2042).