My Weblog

Just another weblog

Configuring BIND on RedHat (DNS under Linux)- Part 2

Configuring BIND on RedHat (DNS under Linux)
Part 2 – Primary Name Server for a Zone

Written by Tony Bhimani
July 21, 2004

RedHat Linux 9
BIND 9.2.1

Now we will configure BIND to be a primary name server for a single zone. I will use the fictitous domain as an example. We will add the hostnames www, ftp, and mail. We will also have BIND respond if no hostname is specified in a query (i.e.

BIND stores its configuration data in named.conf which is located in the /etc directory. This file contains the names of the zones and location of the zone data files that it is responsible for answering queries for. The zone data files are stored by default at /var/named (although you can change this path if you wish). Before you can make any changes I will assume you know which text editor you will be using. I prefer pico, but for this tutorial I will use vi since it has a better chance of being installed by default.

Switch over to the /etc directory and open the named.conf file.

cd /etc
vi named.conf

You should see something that looks like the following.


Scroll through the file and take a look at the contents. Locate the localhost zone.

zone "localhost" IN {
	type master;
	file "";
	allow-update { none; };

Move the cursor on the blank like below the }; and press the i key. The i key puts vi in insert mode (you should see — INSERT — at the botton of vi). Press the enter key once then type in the following. Note: the spacing in front of type, file, and allow-update are tabs, so press the tab key on each of those lines.

zone "" IN {
	type master;
	file "";
	allow-update { none; };

Be sure to put a blank line underneath the }; when you are done. It always helps to keep your files neat and clean. Now we will save the file. Press ESC and vi should leave insert mode (– INSERT — at the bottom of vi should disappear). Now type :wq and enter. vi should write our changes and exit back to the prompt.


We have told BIND that we handle the domain and the zone data is in the file located at /var/named. Now we have to create the file.

Switch over to /var/named and make a copy of the file and save it as This will give us a template to work with so we don’t have to type as much. It also saves us from changing the file’s owner, group, and permissions.

cd /var/named

You should get something that looks like this.


Put vi in insert mode and alter the zone file so it looks like the data below. Use tabs between items. Where I use you should replace with your public IP address (don’t use local LAN IP’s).

$TTL 86400
@	IN	SOA (
			2004042601	; serial
			21600		; refresh
			3600		; retry
			604800		; expires
			86400 )		; minimum


	IN	MX	10


ns1	IN	A
www	IN	A
ftp	IN	A
mail	IN	A

Let’s briefly go over the values (if you want more details on the contents of a zone file visit).

“” is the name server responsible for When you register a domain name the registrar asks you for the name servers names and IP’s. We have given our name server the name ns1 (i.e. name server 1). So if we were to register, we would use for the name and the IP address of the machine we have designated as our DNS server.

“” is the email address of the administrator in charge of the zone. You replace the @ symbol in the email address with a period. So becomes

The “IN NS” means we are declaring to be a name server.

With “IN MX 10” we are declaring a mail exchange (or mail server) with a priority of 10. Since we only use one mail server the priority has no effect.

The “IN A” means we are declaring a host (with no hostname, so it means and it’s IP is Any queries on just will resolve to This is is useful when you configure your web server to work on or They both point to the same thing and will return the same web site.

The rest of the entries mean we are declaring hosts ns1, www, ftp, and mail (,,, and Since they all share the same IP, each of those services will run from the same machine. If you had the mail server running on a different machine then you would substitute that machines IP address in place of The same goes for the rest of the hosts.

When you are done editing the zone file, it should look like this.


Save it and close out of vi. Press ESC to get out of insert mode, type :wq and press enter. You should be back to the command prompt.

Now we need to tell named (BIND) to load the zone and answer any queries that come in.

/etc/init.d/named reload


Now we can test our domain using nslookup.


You should see something similar to the following screen.


Everything looks good. BIND is resolving our When you are done, type exit and press enter.

Source : – Thx


2 responses to “Configuring BIND on RedHat (DNS under Linux)- Part 2

  1. Pingback: » Blog Archive » Configuring BIND on RedHat (DNS under Linux) - Part 1

  2. moweawyqqw October 31, 2009 at 7:59 am

    NAIKZp qhoxblgdtozw, [url=]qvzamascwkxp[/url], [link=]mitgacotwrex[/link],

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: