Sunday, 6 January 2013

Linux DNS server Configuration

DNS Server Configuration in RHEL 6.0


DNS stands for Domain Name Server. DNS allows systems to look up host names, both within the private network and across the Internet. There are other ways of doing this, for example you could just run identical hosts files on all your machines. 

You can set up the DNS server on any Unix system. I am going to configure in Redhat 6.0. As a result, I'm going to talk about BIND.

To configure the DNS server, you need to set up a number of (text) database files. The DNS server daemon (called named) first consults a boot file. This boot file tells the daemon to consult a series of further database files which gives it enough information to start serving names.

The port number for named server is 53 and bind is the utility used for DNS.

There are different way you can classify the name servers:
1. Master.
2. Slave.
3. Caching only.
4. Forwarding.

I am going to create Caching only named server.

1. Setting up BIND

Step 1: Install the required packages : 
           #  yum install -y bind bind-utils bind-libs

Step 2: Verify that the packages have been installed:
           # rpm -qa | grep ^bind

Step 3: Ensure the services is set to start on boot:
           # chkconfig named on

Step 4: Verify that the service is set to start on boot:
          #  chkconfig --list named 
          named            0:off   1: off    2:on      3:on     4:on     5:on   6:off


2. Configure a DNS server


To begin configuration the DNS server, check out these key config files for a BIND server.

/etc/named.conf                                     Main config file
/etc/named.rfc1912.zone                       Main zone file



Before you do anything, you should make a backup of the /etc/named.conf file:

# cp /etc/named.conf /etc/named.conf.orig
# vi /etc/named.conf


  Line no 11      listen-on port 53 { 192.168.1.25; }; //change the ipaddress of your server.
  Line no 12      #       listen-on-v6 port 53 { ::1; }; //if u want to disable ipv6 then commend this   line.
  //Last line
        include "/etc/named.rfc1912.zones";
   :wq



Step5:     Edit the "/etc/named.rfc1912.zones" file.
              # vi /etc/named.rfc1912.zones 

              ; Append this lines to the configuration file to mention forward and reverse file locations.

              zone "example.com" IN {
                type master;
                file "forward.zone";
                allow-update { none; };
               };


              zone "1.168.192.in-addr.arpa" IN {
                type master;
                file "reverse.zone";
                allow-update { none; };
               };

After that we want to create the forward and reverse file

No need to create the forward and reverse files . The same file for loopback will be edited.
Firstly copy the two files and change the name..

#cp -a /var/named/named.localhost /var/named/forward.zone
#cp -a /var/named/named.loopback /var/named/reverse.zone

Next we want to edit the forward zone file as shown below

# vi forward.zone
$TTL 1D
@       IN SOA  sarin.example.com. root.example.com. (
                                        12122012        ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN      NS      sarin.example.com.
        IN      A       192.168.1.253
sarin              IN      A       192.168.1.25
desktop3        IN      A       192.168.1.26
sarinnath       IN      A       192.168.1.30

Reverse as shown below



# vi reverse.zone 

$TTL 1D
@       IN SOA  sarin.example.com. root.example.com. (
                                        12122012        ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
           IN      NS      sarin.example.com.
@       IN      A       192.168.1.25
25      IN      PTR     sarin.example.com.
26      IN      PTR     desktop3.example.com.
30      IN      PTR     sarinnath.example.com.




Everything is now in place for you to begin using your DNS server. Before starting
the service, however, make sure that the config files don’t have any syntax errors.


Step 1:                  # named-checkconf /etc/named.conf 
                              If this doesn't leave error then your configuration is ok...


Step 2:                   Because no errors are displayed, you can start the service:
                              # service named start
                              Starting named: [ OK ]


DNS Utilities and Troubleshooting


For the server and client, there are a handful of utilities you can use to verify the
functionality of DNS. These utilities include

dig                    DNS lookup utility
host                  DNS lookup utility
ping                  Network or hostname verification utility
nslookup           Utility to lookup a hostname from an IP addresses
hostname          Utility to sets or show the system hostname (FQDN)



At this point, you should have a fully functional  DNS server. Although you
aren’t required to know how to set up a DNS server for the Red Hat exams,
this task is commonly performed in the real world. Thank you..Best of Luck.




No comments:

Post a Comment