How to Install DNS Server in RHEL/CentOS/6.X/7.X

Setup DNS Server in your production server
DNS Server IP address: 192.168.35.141

Install bind/ DNS package
# yum install bind bind-chroot bind-utils

Backup DNS default configuration file
# cp -rpf /etc/named.conf /etc/named.conf.bak

Edit /etc/named.conf file and changed highlighted parameter
# vim /etc/named.conf
options {
        listen-on port 53 { 127.0.0.1; 192.168.35.141;  };
        #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 here only specific network as per requirement}
        recursion yes;
        dnssec-enable yes;
        dnssec-validation yes;
        /* 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";
};
/* Add zone file here */
zone "linuxsolution.in" IN {
        type master;
        file "linux.zone";
        allow-update { none; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

Create Zone file
# cd /var/named
# vim linux.zone
$TTL    86400
@               IN SOA  linuxsolution.in. root.linuxsolution.in. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                   IN NS           linuxsolution.in.
linuxsolution.in.  IN A            192.168.35.141
mailzm             IN A            192.168.35.141
linuxsolution.in.   IN MX   0       mailzm.linuxsolution.in.

Restart DNS service
On CentOS 6.X
# service named restart
# chkconfig named on

On CentOS 7
# systemctl restart named
# systemctl enable named

Make entry in /etc/resolved.conf file as per below
# echo "nameserver 192.168.35.141" >/etc/resolv.conf
# cat /etc/resolv.conf
nameserver 192.168.35.141

Test DNS
# nslookup linuxsolution.in
Server:         192.168.35.141
Address:        192.168.35.141#53
Name:   linuxsolution.in
Address: 192.168.35.141

Check MX record
# host -t mx linuxsolution.in
linuxsolution.in mail is handled by 0 mailzm.linuxsolution.in.

0 Comments