Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is my current DNS zone file. I followed a tutorial. It works, because when I point to this DNS from another server via resolve.conf, it will actually forward me to the right IP when I do "ping".

; BIND data file for
$TTL    604800
@       IN      SOA (
                            2007011501         ; Serial
                                  7200         ; Refresh
                                   120         ; Retry
                               2419200         ; Expire
                                604800)        ; Default TTL
@       IN      NS
@       IN      NS    IN      MX      10    IN      A

www                     IN      CNAME
mail                    IN      A
ftp                     IN      CNAME            IN      TXT     "v=spf1 ip4: a mx ~all"
mail                    IN      TXT     "v=spf1 a -all"

Right now,

ping to That's great!!! it works!

My question is--how can I add something do this file so that when my other servers:

ping dbserver1....goes to
ping cacheserver1 ....goes to

I want to use it like a universal hosts file for my machines.

share|improve this question
up vote 5 down vote accepted

If you want to use as the base domain for all your machines, you must add this to all your machines /etc/resolv.conf file:


Then do as Schof suggested, but split that entry into two lines (minor formatting issue on his post):

dbserver1 IN A
cacheserver1 IN A

Then increment the serial in that zone file (very important). For example, from 2007011501 to 2009091000 (today's date + 00, or 01 in the next update and so on).

Then reload bind9 and try pinging dbserver1 from your machines.

share|improve this answer
Incrementing the serial is only important if other DNS servers are fetching DNS from his server. If it's a purely local server with only DNS clients using it, the serial number isn't such a big deal. – Schof Nov 10 '09 at 0:56
That's true, thanks for pointing that out. – Yves Junqueira Nov 10 '09 at 1:09

If I understand your question correctly, you're very close to where you want to go:

Assuming you want, and not, do the following:

dbserver1 IN A
cacheserver1 IN A

If you want to go to some other domain (as your comment indicates) then you'd want: IN A IN A

(Note the terminating period on the domain names above. Very important; otherwise you'll get

Moving away from the specific topic of BIND config files to the general topic of DNS, I'm not sure what you're trying to do, but it doesn't sound like a good idea.

The Internet moved away from hosts files to DNS because maintaining a bunch of hosts files quickly became impossibly arduous. If you're using DNS to create your own hosts file, I'd suggest:

  1. Using an actual hosts file.
  2. Not doing it at all and using DNS as DNS.

If you just want to be able to go to by typing "ping dbserver1" then you need to follow Yves' suggestion and add "search" to your /etc/resolv.conf. This is completely independent of your DNS server -- it's a local setting on each machine telling it to append "" to invalid addresses.

share|improve this answer
Yes, I want to go to a certain IP. However, I don't want "" anywhere!! Especially the .com. Can I do dbserver1.main --> – Alex Nov 10 '09 at 0:42
Yeah, you can do that by following Yves' and mine suggestions about adding "search" to your resolv.conf file. – Schof Nov 10 '09 at 0:53
thanks a lot. s – Alex Nov 10 '09 at 0:57

For add other DNS entry in your linux DNS Server..go

vi /etc/named.caching-nameserver.conf

and add below dns server IP

forwarders {; };


service named restart

and check it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.