DNS Server configuration in CentOS step by step

DNS (Domain Name System) translates hostnames or URLs into IP addresses. For example if we type  kirtikumarpatel.blogspot.in  in browser, the DNS server translates the domain name into its associated ip address. Since the IP addresses are hard to remember, DNS servers are used to translate the hostnames like ansh.kirtipatel.com to 192.xxx.xx.xxx. So it makes easy to remember the domain names instead of its IP address.

Scenario

Primary(Master) DNS Server Details:
Operating System     : CentOS 6.5 server
Hostname             : ansh.kirtipatel.com
IP Address           : 192.168.1.100/24
Setup Primary(Master) DNS Server
[root@ansh ~]# yum install bind* -y


1. Configure DNS Server
First go to /etc/hosts file

[root@ansh ~]# vi /etc/hosts

and add hostname with ip address

192.168.1.100   ansh.kirtipatel.com ansh

Add the lines as shown below in ‘/etc/named.conf’ file

[root@masterdns ~]# vi /etc/named.conf 
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
listen-on port 53 { 127.0.0.1; 192.168.1.100; }; ### Master DNS IP ###
#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; };
allow-transfer{ localhost; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
zone "." IN {
type hint;
file "named.ca";
};
zone"kirtipatel.com" IN {
type master;
file "forward.com.zone";
allow-update { none; };
};
zone"1.168.192.in-addr.arpa" IN {
type master;
file "reverse.com.zone";
allow-update { none; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

U can also add Zone entry in /etc/named.rfc1912.zones 
if u not put this line here..

2. Create Zone files
Create forward and reverse zone files which we mentioned in the ‘/etc/named.conf’ file.

2.1 Create Forward Zone
Create forward.com.zonefile in the ‘/var/named’ directory.
[root@ansh ~]# vi /var/named/forward.com.zone
$TTL 86400
@   IN  SOA     ansh.kirtipatel.com. root.ansh.kirtipatel.com. (
        2011071001  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
@       IN  NS          ansh.kirtipatel.com.


ansh       IN  A   192.168.1.100 
2.2 Create Reverse Zone
Create reverse.com.zone file in the ‘/var/named’ directory.
[root@ansh ~]# vi /var/named/reverse.com.zone 
$TTL 86400
@   IN  SOA     ansh.kirtipatel.com. root.ansh.kirtipatel.com. (
        2011071001  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
@       IN  NS          ansh.kirtipatel.com.


100      IN  PTR   ansh.kirtipatel.com.

2.2 change ownership
[root@ansh ~]# cd /var/named
[root@ansh ~]#chown root:named forward.com.zone
[root@ansh ~]#chown root:named reverse.com.zone
3. Start the DNS service
[root@ansh ~]# service named start
Starting named:                                            [  OK  ]
[root@ansh ~]# chkconfig named on

After That u will try to check with nslookup and dig commang.

Comments

Post a Comment

Popular posts from this blog

Step By Step Configuration Cisco VoIP Phone in Cisco Packet Tracer.

How To Setup Social Publishing CMS (Content Managemnet System) Using Pligg in CentOS 6.5

How To Install And Configuring OpenFire XMPP Chat server on centos 6.5