How to Setup Master Slave DNS Server on CentOS Server

Posted on May 18th, 2017

In this tutorial we can check how to setup master slave DNS server on CentOS server.

Domain Name System (DNS) is a distributed system that translates a domain name to IP address and vice versa.

 

Steps to Install DNS server

Install required RPM packages on both Master and slave servers.

 # yum install bind bind-chroot

1)Setup master DNS server(ns1).

a) Add the code below to configure the named.conf

Vi /etc/named/named.conf

options {

listen-on port 53 { 127.0.0.1; IP/24; };

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; IP/24; };

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 “domInname.com” IN {

  • type master;

file “/var/named/domainname.com.db”;

allow-update { none; };

};

 

include “/etc/named.rfc1912.zones”;

 

Change IP and domainname.com with your IP address and domain name.

 

b) Create a zone file for the domain.

#vi /etc/named/domain.com.db

; Zone file for domain.com

$TTL 14400

@      86400    IN      SOA     ns1.domain.com. webmaster.domain.com. (

3215040200      ; serial, todays date+todays

86400           ; refresh, seconds

7200            ; retry, seconds

3600000         ; expire, seconds

86400 )         ; minimum, seconds

 

Domain.com. 86400 IN NS ns1.domain.com.

Domain.com. 86400 IN NS ns2.domain.com.

Domain,com. IN A IP

Domain.com. IN MX 0 domain.com.

mail IN CNAME domain.com.

www IN CNAME domain.com.

 

c) Restart the DNS service to enable the changes.

# /etc/init.d/named restart

# chkconfig named on

 

2) Steps to setup a slave (ns2) DNS

a) In slave server we need to configure only named.conf file. All other zones will be automatically synced with the master server. Add the following code to named.conf file.

Vi /etc/named/named.conf

options {

listen-on port 53 { 127.0.0.1; IP/24; };

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; IP/24; };

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 “domain.com” IN {

type slave;

file “slaves/Domain.com.db”;

masters { master server IP; };

};

 

include “/etc/named.rfc1912.zones”;

 

Replace domainname.com with your domain, IP with your server IP and master IP with your master server IP.

 

b) Finally, restart the services for enabling the changes.

# /etc/init.d/named restart

# chkconfig named on

 

You can verify the connection using the command

 #nslookup domainname.com master IP

#nslookup domainname.com slave IP

 

If you need any further help please contact our support department.

 

 

Leave a Reply