Installing BIND

Hosting your own DNS (nameserver) is really simple, and will take you just a few minutes to get up and running. There are only 5 files that need configuration in order for your DNS to be operational, and the whole process is rather intuitive.

To begin, you must first install the server application itself. Because BIND (Berkeley Internet Name Daemon) is the most * commonly used nameserver by far, we will be using that one here. The following command will install version 9, which is the latest.

apt-get install bind9 dnsutils

Configure BIND

Now for the fun part. There are several files that need at least minimal configuration:

file Purpose
named.conf.local To tell your DNS what your domain is, and where to find its zone file
named.conf.options To specify a stable IP that can take over if yours fails.
resolv.conf To specify the IP address of your nameserver
zone file Where to point your domain and subdomains to their servers
reverse DNS zone file This does the opposite of the zone file


Configuration of your Bind server occurs in the named.conf.local file. That is where you will add your zones. You may edit the file using your favorite editor, for example if you use nano, simply type:

nano /etc/bind/named.conf.local

Then, to add a zone to your server, add the following (replace both instances of “domain.tld” with the zone that you want to serve:

 zone "domain.tld" {
      type master;
      file "/etc/bind/zones/domain.tld.db";


Be sure to edit the named.conf.options file:

nano /etc/bind/named.conf.options

If you want to resolve many domain names on your primary server, it is necessary to add instructions indicating the configuration files to use for each of your domains. In that file, you also have to specify the IP address of the secondary server to use, in order to allow zone transfers.

For example, here is the configuration for domain.tld, using as secondary server:

zone "domain.tld" (
        type master;
        allow-transfer {;};
        file "/etc/bind/db.domain.tld";

The setting must be performed for each domain name that need to be resolved on your primary server, and must contain the IP information of the secondary server in order to allow zone transfer.


You will want to edit the resolv.conf file, and tell it the IP address of your name server. Note that it is not found in the bind folder with your other files, but in the /etc directory. To edit it, type:

nano /etc/resolv.conf  

Simply add the following, being sure to replace “domain.tld” with your domain, and replace “” with IP address of your nameserver (don't know what it is?). Anything after the first nameserver are secondary nameservers. In the below example I am using Gandi's nameserver as a secondary nameserver.

search domain.tld

zone files

The files that contain the records where you point your domain name to your hosting server, or your mail server are called the 'zone files' or the 'zone definition files'. The content of these corresponds to what you use when you edit your zone file on Gandi's interface (more) when using Gandi's default DNS.

1. Begin by making the zones directory: This is the folder that will hold all your zone files.

mkdir /etc/bind/zones

2. Make the zone files for your domains

You will now need to create your zone file where the addresses and machine names that your DNS server will use (in the following example, replace domain.tld with your domain). Use the following command to create the file (replace domain.tld with your domain):

nano /etc/bind/zones/domain.tld.db

Here is a sample zone file:

$TTL    10800
@  IN   SOA   ns1.domain.tld. admin.domain.tld. (
@ IN NS ns1.domain.tld.
@ 10800 IN MX 10
@ 10800 IN MX 50
pop 10800 IN CNAME
imap 10800 IN CNAME
smtp 10800 IN CNAME
webmail 10800 IN CNAME
mta IN A
ns1 IN A

(you will obviously replace the values with your own. Here we are showing a zone using Gandi's mail servers and configured for GandiMail, and our own HTTP servers).

As you can see, the second half of this zone file resembles the 'expert interface' in Gandi's DNS management page. This is because it is the same thing! You would therefore enter the same commands in your zone file, as you would if you were entering them in your Gandi DNS zone file.

Reverse DNS zone files

Begin my making your file (replace 190.70.217 with your network address backwards).

nano /etc/bind/zones/

Then create the following code, replacing:

  • 'domain.tld.' with your own domain name
  • 'ns1.domain.tld.' with your own DNS server name
  • The number '17' with your machine's number (ex. if your IP address is, this would be the final number, or in this case '17')
@ IN SOA domain.tld.  admin.domain.tld. (

                     IN    NS     ns1.domain.tld.
17                   IN    PTR    domain.tld.


Once you have configured your DNS server, you must restart it:

/etc/init.d/bind9 restart

If everything works, you will see the following:

Stopping domain name service... bind                                         [ OK ]
Starting domain name service... bind                                         [ OK ]

Installing a BIND server: Give it a go! provides flexible and dedicated webhosting resources that you can use to host as many domain names/websites as you wish. Our service is without any minimum contractual period and you can create a powerful server in just 10 minutes beginning at just $14 per month. For more on this, go to our hosting page at

Last modified: 10/01/2015 at 10:30 by Ryan A. (Gandi)