You are on page 1of 7

configuring dns server on red-hat PARTIE 2

Change in Primary DNS Server:

Step-1: Edit the named.conf file for Secondary DNS .


[root@ns1 ~]# vi /etc/named.conf

//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver 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.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
options {
listen-on port 53 { 127.0.0.1;192.168.1.20; };
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";

// Those options should be used carefully because they disable port


// randomization
// query-source port 53;
// query-source-v6 port 53;

allow-query { localhost;192.168.1.0/24; };
allow-query-cache { localhost;192.168.1.0/24; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
//view localhost_resolver {
//match-clients { localhost; };
//match-destinations { localhost; };
//recursion yes;
//include "/etc/named.rfc1912.zones";
//};
zone "tmsir.ma" IN {
type master;
file "tmsir.zone";
allow-transfer { 192.168.1.30; };
notify yes ;
allow-update {192.168.1.30;}
};

zone "1.168.192.in-addr.arpa" IN {
type master;
file "tmsir.rev";
allow-transfer { 192.168.1.30; };
notify yes ;
allow-update {192.168.1.30;}
};

Step-2:  Edit Forward Lookup zone file for Secondary DNS server record
[root@ns1 ~]# cd /var/named/chroot/var/named/
[root@ns1 named]# gedit tmsir.zone

Original File:  tmsir.zone

$TTL 86400
@ IN SOA srv.tmsir.ma. root.tmsir.ma. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum

IN A 127.0.0.1
IN AAAA ::1
@ IN NS srv.tmsir.ma.
@ IN NS srv1.tmsir.ma.
srv.tmsir.ma. IN A 192.168.1.10
srv1.tmsir.ma. IN A 192.168.1.20
pc1.tmsir.ma. IN A 192.168.1.11
pc2.tmsir.ma. IN A 192.168.1.12
www         IN  CNAME  ns1.tmsir.ma.

 Step-3:  Edit Reverse Lookup zone file for Secondary DNS server record
[root@ns1 named]# gedit tmsir.rev

$TTL 86400
@ IN SOA srv.tmsir.ma. root.tmsir.ma. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum

IN A 127.0.0.1
IN AAAA ::1

@ IN NS srv.tmsir.ma.
@ IN NS srv1.tmsir.ma.
10 IN PTR srv.tmsir.ma.
20 IN PTR srv1.tmsir.ma.
11 IN PTR pc1.tmsir.ma.
12 IN PTR pc2.tmsir.ma.
Step-4:    Check the named.conf & zone file by following this commands,
[root@ns1 ~]# named-checkconf  /var/named/chroot/etc/named.conf 
[root@ns1 ~]# named-checkzone tmsir.ma  /var/named/chroot/var/named/tmsir.zone
[root@ns1 ~]# named-checkzone  tmsir.ma   /var/named/chroot/var/named/tmsir.rev

Step-5:  Edit the resolv.conf file by following this command


[root@ns1 named]# vi /etc/resolv.conf
search tsmir.ma
nameserver 192.168.1.10
nameserver 192.168.1.20

Step-6:  Start & stop all the required services.


[root@ns1 ~]# service iptables stop
[root@ns1 ~]# service network restart
[root@ns1 ~]# chkconfig named on
[root@ns1 ~]# service named restart

CONFIGURATION DE SERVEUR DNS SECONDIARE:

Step-1:  To check bind and caching-nameserver  rpm package is installed or not by following this                     
command:
                       
(if installed then it will show bind packages)

[root@ns2 ~]# rpm -qa | grep –i bind*    or


[root@ns2 ~]#  rpm –qa bind*
bind-chroot-9.3.6-4.P1.el5
bind-libs-9.3.6-4.P1.el5
ypbind-1.19-12.el5
bind-9.3.6-4.P1.el5
bind-utils-9.3.6-4.P1.el5
bind-sdb-9.3.6-4.P1.el5
bind-devel-9.3.6-4.P1.el5
bind-libbind-devel-9.3.6-4.P1.el5
system-config-bind-4.0.3-4.el5

[root@ns2 ~]# rpm -qa caching-nameserver*  


Caching-nameserver-9.3.6-4.P1.el5

            If not installed, then installed the packages using  Yum command:
[root@ns2 ~]# Yum Install bind* caching-nameserver*
Step-2: Check and Configure the Network Card:

[root@ns2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

(Original File):
#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes

(Modified File):
#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes
TYPE=Ethernet
PEERDNS=no
USERCTL=no
IPV6INIT=no
IPADDR=192.168.1.20
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255

After changing you have to reload/restart the NIC(eth0) card by following command:
[root@ns2 ~]# ifdown eth0
[root@ns2 ~]# ifup eth0
[root@ns2 ~]# service network restart

Step-3:  After complete the NIC configure you have to change the host name by following this                             
command:
[root@ns2 ~]# vi /etc/sysconfig/network

(Original File):
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain

(Modified File):
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=srv1

Step-4: Now Edit hosts file for host name resolution by following this command:


[root@ns2 ~]# vi /etc/hosts
(Original File):
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost

(Modified File):
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
192.168.1.10   srv.tmsir.ma srv
192.168.1.20   srv1.tmsir.ma    srv1

Step-5:  Copy & Rename the named.rfc1912.zones file to named.conf file & Change the ownership &
permission by following this command:
[root@ns2 ~]# cd /var/named/chroot/etc/
[root@ns2 etc]# cp named.caching-nameserver.conf  named.conf
[root@ns2 etc]# chown root:named named.conf
[root@ns2 etc]# chmod 777 named.conf

Now Create A Link into /etc directory of named.conf then edit.


[root@ns2 etc]# ln –s /var/named/chroot/etc/named.conf  /etc/named.conf
[root@ns2 ~]# gedit /etc/named.conf

fichier source
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver 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.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
options {
listen-on port 53 { 127.0.0.1; };
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";

// Those options should be used carefully because they disable port


// randomization
// query-source port 53;
// query-source-v6 port 53;

allow-query { localhost; };
allow-query-cache { localhost; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { localhost; };
match-destinations { localhost; };
recursion yes;
include "/etc/named.rfc1912.zones";
};

le fichier a prés modification :


//
// named.caching-nameserver.conf
// Provided by Red Hat caching-nameserver 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.
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
options {
listen-on port 53 { 127.0.0.1;192.168.1.11; };
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";

// Those options should be used carefully because they disable port


// randomization
// query-source port 53;
// query-source-v6 port 53;

allow-query { localhost;192.168.1.0/24; };
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
//view localhost_resolver {
//match-clients { localhost; };
//match-destinations { localhost; };
//recursion yes;
//include "/etc/named.rfc1912.zones";
//};
zone "tmsir.ma" IN {
type slave;
file "tmsir.zone";
masters { 192.168.1.10; };
allow-notify {192.168.1.20; };
};
zone "1.168.192.in-addr.arpa" IN {
type slave;
file "tmsir.rev";
masters { 192.168.1.10; };
allow-notify {192.168.1.20; };

};

Step-6:  Now change the ownership & permission of  named directory

[root@ns2 ~]# chown root:named /var/named/chroot/var/named/


[root@ns2 named]# chmod 777 /var/named/chroot/var/named/

Step-7:  Edit the resolv.conf file by following this command


[root@ns2 named]# gedit /etc/resolv.conf
search tmsir.ma
nameserver 192.168.1.10
nameserver 192.168.1.20

Step-8:  Start the named service, that it will automatically copy the forward & reverse lookup zone file    from
Primary DNS server.
[root@ns2 ~]# service iptables stop
[root@ns2 ~]# service network restart
[root@ns2 ~]# chkconfig named on
[root@ns2 ~]# service named restart

Step-9: Check the DNS server by following this command. Also check the Primary DNS from         
secondary DNS.
[root@ns2 ~]# host 192.168.1.20
[root@ns2 ~]# host srv1.tmsir.ma
[root@ns2 ~]# Ping srv1.tmsir.ma
[root@ns2 ~]# nslookup srv1.tmsir.ma
[root@ns2 ~]# nslookup 192.168.1.20
[root@ns2 ~]# dig srv2.tmsir.ma
[root@ns2 ~]# dig –x 192.168.1.20
[root@ns2 ~]# dig –x srv1.tmsir.ma
[root@ns2 ~]# dig –t SOA tmsir.ma
[root@ns2 ~]# dig –t axfr tmsir.ma

You might also like