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 opeational, 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

named.conf.local

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 “whack-a-mole.eu” with the zone that you want to serve:

zone "whack-a-mole.eu" {
      type master;
      file "/etc/bind/zones/whack-a-mole.eu.db";
      };

named.conf

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 whack-a-mole.eu, using ns6.gandi.net as secondary server:

zone "whack-a-mole.eu" (
        type master;
        allow-transfer {217.70.177.40;};
        file "/etc/bind/db.whack-a-mole.eu";
)

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.

resolv.conf

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 “whack-a-mole.eu” with your domain, and replace “217.70.190.17” 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 ns6.gandi.net nameserver as a secondary nameserver.

search whack-a-mole.eu
nameserver 217.70.190.17
nameserver 217.70.177.40

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 whack-a-mole.eu with your domain). Use the following command to create the file (replace whack-a-mole.eu with your domain):

nano /etc/bind/zones/whack-a-mole.eu.db

Here is a sample zone file:

whack-a-mole.eu.  IN   SOA   boom.whack-a-mole.eu. admin.whack-a-mole.eu. (

2006081401
28800
3600
604800
38400
)
  
whack-a-mole.eu. IN NS boom.whack-a-mole.eu.

whack-a-mole.eu. 10800 IN MX 10 spool.mail.gandi.net.
whack-a-mole.eu. 10800 IN MX 50 fb.mail.gandi.net.
pop 10800 IN CNAME access.mail.gandi.net.
imap 10800 IN CNAME access.mail.gandi.net.
smtp 10800 IN CNAME relay.mail.gandi.net.
webmail 10800 IN CNAME agent.mail.gandi.net.

www IN A 217.70.190.20
mta IN A 217.70.190.17
boom IN A 217.70.190.17

(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/rev.190.70.217.in-addr.arpa

Then create the following code, replacing:

  • 'whack-a-mole.eu.' with your own domain name
  • 'boom.whack-amole.eu.' with your own DNS server name
  • The number '17' with your machine's number (ex. if your IP address is 190.70.217.17, this would be the final number, or in this case '17')
@ IN SOA whack-a-mole.eu. admin.whack-a-mole.eu. (
                      2006081401;
                      28800;
                      604800;
                      604800;
                      86400);

                     IN    NS     boom.whack-a-mole.eu.
17                   IN    PTR    whack-a-mole.eu.

Restart

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!

Gandi.net 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 http://www.gandi.net/hosting/

Last modified: 01/29/2013 at 10:50 by Lyubomir G. (Gandi)