HOW DO I CONFIGURE DNS SERVER IN LINUX 6
Here Im Using RHEL
Server to Setup the DNS Server using BIND
[root@masterdns ~]# lsb_release -a
LSB Version:
:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat
Enterprise Linux Server release 6.2 (Santiago)
Release: 6.2
Codename: Santiago
Primary DNS Server
(or) Master DNS Server:
IP Address :
192.168.0.200
Hostname : masterdns.linuxzadmin.local
Secondary DNS Server
(or) Slave DNS Server:
IP Address :
192.168.0.201
Hostname : slavedns.linuxzadmin.local
Nodes Machines :
IP Address :
192.168.0.205 ## Hostname :
node1.linuxzadmin.local
IP Address :
192.168.0.206 ## Hostname :
node2.linuxzadmin.local
IP Address : 192.168.0.207 ## Hostname : node3.linuxzadmin.local
IP Address :
192.168.0.208 ## Hostname :
node4.linuxzadmin.local
1.
Primary DNS Server (or) Master DNS Server :
[root@masterdns ~]# yum install bind* -y
1.
Then Edit the Configuration of name server
[root@masterdns ~]# vim /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.0.200; }; # Master DNS Servers 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 { localhost; 192.168.0.0/24; }; # IP Range
of Hosts
allow-transfer { localhost; 192.168.0.201; }; # Slave DNS
Servers IP
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"linuxzadmin.local" IN {
type master;
file "forward.linuxzadmin";
allow-update { none; };
};
zone"0.168.192.in-addr.arpa" IN {
type master;
file "reverse.linuxzadmin";
allow-update { none; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
Save and Exit the
named.conf using wq!
1.
Creat the Forward and Reserve Zone files as mentioned in
named.conf
FORWARD ZONE :
a.) Create a Forward
Zone file under /var/named in the name of forward.linuxzadmin
There are Sample files
under the /var/named/ Directory, Just make a Copy of that file and modify it as
our need
b.) Make a Copy of
sample file as below
[root@masterdns ~]# cp /var/named/named.localhost
/var/named/forward.linuxzadmin
c.) Edit the file
forward.linuxzadmin
[root@masterdns ~]# vim /var/named/forward.linuxzadmin
$TTL 86400
@ IN SOA masterdns.linuxzadmin.local. root.linuxzadmin.local.
(
2014051001 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ; minimum
)
@ IN NS
masterdns.linuxzadmin.local.
@ IN NS
slavedns.linuxzadmin.local.
@ IN A
192.168.0.200
@ IN A
192.168.0.201
@ IN A
192.168.0.205
@ IN A
192.168.0.206
@ IN A
192.168.0.207
@ IN A
192.168.0.208
masterdns IN A
192.168.0.200
slavedns IN A
192.168.0.201
node1 IN A
192.168.0.205
node2 IN A
192.168.0.206
node3 IN A
192.168.0.207
node4 IN A
192.168.0.208
RESERVE ZONE:
a.) Create a Reserver
Zone file under /var/named in the name of reverse.linuxzadmin
There are Sample files
under the /var/named/ Directory, Just make a Copy of that file and modify it as
our need
b.) Make a Copy of
sample file as below
[root@masterdns ~]# cp /var/named/named.loopback
/var/named/reverse.linuxzadmin
c.) Edit the file
reverse.linuxzadmin
[root@masterdns ~]# vim /var/named/reverse.linuxzadmin
$TTL 86400
@ IN SOA masterdns.linuxzadmin.local.
root.linuxzadmin.local. (
2014051001 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ; minimum
)
@ IN NS
masterdns.linuxzadmin.local.
@ IN NS
slavedns.linuxzadmin.local.
@ IN PTR
linuxzadmin.local.
masterdns IN A
192.168.0.200
slavedns IN A
192.168.0.201
node1 IN A
192.168.0.205
node2 IN A
192.168.0.206
node3 IN A
192.168.0.207
node4 IN A
192.168.0.208
200 IN PTR
masterdns.linuxzadmin.local.
201 IN PTR
slavedns.linuxzadmin.local.
205 IN PTR
node1.linuxzadmin.local.
206 IN PTR
node2.linuxzadmin.local.
207 IN PTR
node3.linuxzadmin.local.
208 IN PTR node4.linuxzadmin.local.
1.
The files we created was in root group We need to change those
files to named group
Here we can see the
files which have the root group
a.) List the files and
see the permissions and group of those created zone files
[root@masterdns ~]# ls -l /var/named/
total 40
drwxr-x---. 6 root named
4096 May 10 19:33 chroot
drwxrwx---. 2 named named 4096 Nov 16 2011 data
drwxrwx---. 2 named named 4096 Nov 16 2011 dynamic
-rw-r-----. 1 root
root 550 May 10 20:19
forward.linuxzadmin
-rw-r-----. 1 root named
1892 Feb 18 2008 named.ca
-rw-r-----. 1 root
named 152 Dec 15 2009 named.empty
-rw-r-----. 1 root
named 152 Jun 21 2007 named.localhost
-rw-r-----. 1 root
named 168 Dec 15 2009 named.loopback
-rw-r-----. 1 root root 676 May 10 20:35 reverse.linuxzadmin
drwxrwx---. 2 named named 4096 Nov 16 2011 slaves
b.) Change the group
to named using below Command
[root@masterdns ~]# chgrp named /var/named/forward.linuxzadmin
[root@masterdns ~]# chgrp named /var/named/reverse.linuxzadmin
Here we can see the
Output now which changed to named group
[root@masterdns ~]# ls -l /var/named/
total 40
drwxr-x---. 6 root named
4096 May 10 19:33 chroot
drwxrwx---. 2 named named 4096 Nov 16 2011 data
drwxrwx---. 2 named named 4096 Nov 16 2011 dynamic
-rw-r-----. 1 root
named 550 May 10 20:19
forward.linuxzadmin
-rw-r-----. 1 root named
1892 Feb 18 2008 named.ca
-rw-r-----. 1 root
named 152 Dec 15 2009 named.empty
-rw-r-----. 1 root
named 152 Jun 21 2007 named.localhost
-rw-r-----. 1 root
named 168 Dec 15 2009 named.loopback
-rw-r-----. 1 root
named 676 May 10 20:35
reverse.linuxzadmin
drwxrwx---. 2 named named 4096 Nov 16 2011 slaves
c.) Then we need to
check the Context of the files under
[root@masterdns ~]# ls -lZd /etc/named.conf
-rw-r-----. root named system_u:object_r:named_conf_t:s0
/etc/named.conf
/etc/named.conf
/var/named/forward.linuxzadmin
/var/named/reverse.linuxzadmin
It want to be in the
context of named_conf_t
If its Different than
this then we need to restore the context using
# restorecon /etc/named.conf
1.
Now we need to Check for the Error in the conf file and Zone
file
[root@masterdns ~]# named-checkconf /etc/named.conf
[root@masterdns ~]# named-checkzone linuxzadmin.local /var/named/forward.linuxzadmin
zone linuxzadmin.local/IN: loaded serial 2014051001
OK
[root@masterdns ~]# named-checkzone 0.168.192.in-addr.arpa
/var/named/reverse.linuxzadmin
zone 0.168.192.in-addr.arpa/IN: loaded serial 2014051001
OK
1.
Start the DNS Service
[root@masterdns ~]# service named restart
Stopping named:
[ OK ]
Starting named:
[ OK ]
Comments
Post a Comment