How-To: Setting up a DNS zone with Bind9

2 minute read

Bind is a well known Unix name server, it is a powerfull piece of software which is used by the majority of nameservers.

This article will go though setting up a local area network that can be used at home or inside a small company.

In this article, we suppose that we are going to set a DNS zone for the domain:, this is a fictionnal zone which is going to be used as a local network domain such as an intranet.

The name server is not accessible from the outside and only has 1 private LAN adress network interface.

All other computer in the LAN are going to use as a nameserver, this can be set manually by setting statically:


in their /etc/resolv.conf files, or via a DHCP server (beyond the scope of this article).

In the end, the nameserver is going to provide name resolution as well as reverse name resolution for our local network. For the rest of the domain name, it will query other DNS server and cache the result, behaving as a resolving, caching name server.

In the first part we are going to deal with name resolution and then in the second part, we are going to set up the reverse name resolution.

1. Requirements

This how-to has been made using bind9, first of all, you need to install this package:

sudo apt-get install bind9

Now, we are going to set up domain name.

2. Setting up Domain name resolution

edit the local configuration file:

sudo vi /etc/bind/named.conf.local

and at the following entry:

zone "" {
    type master;
    file "";
    notify no;

As I don’t use any slave server in that example, I turn the value of notify to no.

What we say here, is that we are the master server for, and the configuration file of that zone will be located at: /var/cache/bind/

Notice: the directory value (/var/cache/bind/) might vary depending on your distribution. Check its value in /etc/bind/named.conf.options .On a Ubuntu Dapper, the default value is: options { directory "/var/cache/bind"; .... ....

Now, we are going to fill up the required values to define the domain

Create and edit /var/cache/bind/, and add:

; Zone file for
; The full zone file
@       IN      SOA (
                        200608081       ; serial, todays date + todays serial # 
                        8H              ; refresh, seconds
                        2H              ; retry, seconds
                        4W              ; expire, seconds
                        1D )            ; minimum, seconds
                NS      ns              ; Inet Address of name server
                MX      10 mail         ; Primary Mail Exchanger
                MX      20 mail2        ; Secondary Mail Exchanger
ns              A
www             CNAME
ftp             CNAME   ns
gw              A
                TXT     "Network gateway"
mail            A
mail2           CNAME   otherbox
otherbox         A
                TXT     "Otherbox"

In this file, we define:

  1. the adress of the name server;,
  2. an alias from to, (mind the dot.” at the end of an external name),
  3. another alias from to,
  4. An adresse for the local network gateway with a description

From now on, any machine from your local network, using this name server, will be able to access the others using the domain names we defined above instead of IP adresses. On the second part of this tutorial, we will set up reverse name resolution.