Before configuring DNS server first know a little of it. DNS is Domain Naming Service which resolves Name to IP and IP to Name because it's difficult to remember IP address of every site every time. So DNS server resolves IP addresses to website name for us. Let's how to configure it.

[root@dns ~]# yum install bind -y

Now edit /etc/named.conf  and named.rfc1912.zones file.

[root@dns ~]# vim /etc/named.conf

options {
        listen-on port 53 { 192.168.85.2; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { any; };

        recursion yes;

Change two lines show above


  • 192.168.85.2 is server ip where you are installing dns server.
  • allow -query to any
Fine the below  sections in /etc/named.rfc1912.zones file

[root@dns ~]# vim /etc/named.rfc1912.zones

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


##############################

zone "1.0.0.127.in-addr.arpa" IN {
        type master;
        file "named.loopback";
        allow-update { none; };

Edit them as below
[root@dns ~]# vim /etc/named.rfc1912.zones

zone "gil.com" IN {
        type master;
        file "gil.for";
        allow-update { none; };


##############################

zone "85.168.192.in-addr.arpa" IN {
        type master;
        file "gil.rev";
        allow-update { none; };

  • gil.com is domain name 
  • gil.for  and gil.rev are forward and reverse lookup zones, you name as you wish
Now copy sample zone files and edit them

[root@dns ~]# cp /var/named/named.localhost /var/named/gil.for
[root@dns ~]# cp /var/named/named.loopback /var/named/gil.rev

Now it's time to change group for both forward and revers zones to named group.

[root@dns ~]# chgrp named /var/named/gil.for
[root@dns ~]# chgrp named /var/named/gil.rev

Edit forward zone file  /var/named/gil.for

[root@dns ~]# cp /var/named/gil.for



$TTL 1D
@       IN SOA  dns.gil.com. root.gil.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       IN NS   dns.gil.com.
dns     IN A    192.168.85.9

Edit forward zone file  /var/named/gil.rev

[root@dns ~]# cp /var/named/gil.rev

$TTL 1D
@       IN SOA dns.gil.com. root.dns.gil.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       IN  NS  dns.gil.com.
dns     IN  A   192.168.85.9
9       IN  PTR dns

We are done with editing forward & reverse zones, lets check all the file to know if there are any errors.


[root@dns ~]# named-checkconf /etc/named.conf
[root@dns ~]# named-checkconf /etc/named.rfc1912.zones
[root@dns ~]# named-checkzone gil.com /var/named/gil.for
zone gil.com/IN: loaded serial 0
OK
[root@dns ~]# named-checkzone gil.com /var/named/gil.rev
zone gil.com/IN: loaded serial 0
OK

all the named files and zone files are ok no errors. Now it's time to dig.

[root@dns ~]# dig gil.com NS

; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> gil.com NS
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36079
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;gil.com.            IN    NS

;; ANSWER SECTION:
gil.com.        86400    IN    NS    dns.gil.com.

;; ADDITIONAL SECTION:
dns.gil.com.        86400    IN    A    192.168.85.9

;; Query time: 0 msec
;; SERVER: 192.168.85.9#53(192.168.85.9)
;; WHEN: Mon May 21 00:34:39 2012
;; MSG SIZE  rcvd: 59

[root@dns ~]# dig dns.gil.com

; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> dns.gil.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49083
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;dns.gil.com.            IN    A

;; ANSWER SECTION:
dns.gil.com.        86400    IN    A    192.168.85.9

;; AUTHORITY SECTION:
gil.com.        86400    IN    NS    dns.gil.com.

;; Query time: 0 msec
;; SERVER: 192.168.85.9#53(192.168.85.9)
;; WHEN: Mon May 21 00:34:42 2012
;; MSG SIZE  rcvd: 59

[root@dns ~]# nslookup dns.gil.com
Server:        192.168.85.9
Address:    192.168.85.9#53

Name:    dns.gil.com
Address: 192.168.85.9

Our DNS server is up and running....