3

This is my current DNS example.com.db 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 example.com".

;
; BIND data file for example.com
;
$TTL    604800
@       IN      SOA     example.com. info.example.com. (
                            2007011501         ; Serial
                                  7200         ; Refresh
                                   120         ; Retry
                               2419200         ; Expire
                                604800)        ; Default TTL
;
@       IN      NS      ns1.example.com.
@       IN      NS      ns2.example.com.
example.com.    IN      MX      10      mail.example.com.
example.com.    IN      A       192.168.254.1


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

Right now,

ping example.com....goes to 192.168.254.1. 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 44.245.66.222
ping cacheserver1 ....goes to 38.221.44.555

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

3 Answers 3

5

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

search example.com

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

dbserver1 IN A 44.245.66.222
cacheserver1 IN A 38.221.44.555

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.

1
  • 1
    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, 2009 at 0:56
2

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

Assuming you want dbserver1.example.com, and not dbserver1.otherdomain.com, do the following:

dbserver1 IN A 44.245.66.222
cacheserver1 IN A 38.221.44.555

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

dbserver1.otherdomain.com. IN A 44.245.66.222
cacheserver1.otherdomain.com. IN A 38.221.44.555

(Note the terminating period on the domain names above. Very important; otherwise you'll get dbserver1.otherdomain.com.example.com.)

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 dbserver1.example.com by typing "ping dbserver1" then you need to follow Yves' suggestion and add "search example.com" 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 "example.com" to invalid addresses.

2
  • Yes, I want dbserver1.example.com to go to a certain IP. However, I don't want "example.com" anywhere!! Especially the .com. Can I do dbserver1.main --> 38.221.44.555?
    – Alex
    Nov 10, 2009 at 0:42
  • Yeah, you can do that by following Yves' and mine suggestions about adding "search example.com" to your resolv.conf file.
    – Schof
    Nov 10, 2009 at 0:53
1

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

vi /etc/named.caching-nameserver.conf

and add below dns server IP

forwarders { 0.0.0.0; };

:wq

service named restart

and check it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .