{"id":2118,"date":"2013-06-27T11:45:19","date_gmt":"2013-06-27T03:45:19","guid":{"rendered":"http:\/\/rmohan.com\/?p=2118"},"modified":"2013-06-27T11:47:42","modified_gmt":"2013-06-27T03:47:42","slug":"master-slave-dns-server-on-centos-6-and-rhel","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=2118","title":{"rendered":"Master Slave DNS Server on CentOS 6 and RHEL"},"content":{"rendered":"<p>How to Setup Master Slave DNS Server on CentOS 6 and RHEL<\/p>\n<p>The DNS ( Domain Name System ) is a distributed system, used for transalate domain names to IP and vice a versa. This article will help you to How to Setup Master Slave DNS Server on CentOS 6 and RHEL Systems.<\/p>\n<p>Network Scenario for this Setup:<\/p>\n<p>Master DNS Server IP: 192.168.1.10 ( ns1.rmohan.net )<br \/>\nSlave DNS Server IP: 192.168.1.11 ( ns2.rmohan.net )<br \/>\nDomain Name : rmohan.net ( For Testing Purpose )<br \/>\nDomain IP : 192.168.1.50 ( For Testing Purpose )<br \/>\nStep 1: Install Required RPMS ( at Master and Slave Both )<\/p>\n<p>Install bind packages at both Master and Slave dns servers using following commands.<\/p>\n<p># yum install bind bind-chroot<br \/>\nStep 2: Setup Master (NS1) DNS Server<\/p>\n<p>There are two types of configuration files in DNS.<\/p>\n<p>One is main dns configuration files named \u201cnamed.conf\u201d<br \/>\nAnother type of configuration file are called zone file. Which is individually created for all domains. named.conf keeps an entry for all zone files.<br \/>\n2.1 Configure named.conf using below configuration<\/p>\n<p># vim \/var\/named\/chroot\/etc\/named.conf<br \/>\nContent of named.conf:<\/p>\n<p>\/\/ \/var\/named\/chroot\/etc\/named.conf<br \/>\noptions {<br \/>\nlisten-on port 53 { 127.0.0.1; 192.168.1.0\/24; };<br \/>\nlisten-on-v6 port 53 { ::1; };<br \/>\ndirectory &#8220;\/var\/named&#8221;;<br \/>\ndump-file &#8220;\/var\/named\/data\/cache_dump.db&#8221;;<br \/>\nstatistics-file &#8220;\/var\/named\/data\/named_stats.txt&#8221;;<br \/>\nmemstatistics-file &#8220;\/var\/named\/data\/named_mem_stats.txt&#8221;;<br \/>\nallow-query { localhost; 192.168.1.0\/24; };<br \/>\nrecursion yes;<\/p>\n<p>dnssec-enable yes;<br \/>\ndnssec-validation yes;<br \/>\ndnssec-lookaside auto;<\/p>\n<p>\/* Path to ISC DLV key *\/<br \/>\nbindkeys-file &#8220;\/etc\/named.iscdlv.key&#8221;;<\/p>\n<p>managed-keys-directory &#8220;\/var\/named\/dynamic&#8221;;<br \/>\n};<\/p>\n<p>logging {<br \/>\nchannel default_debug {<br \/>\nfile &#8220;data\/named.run&#8221;;<br \/>\nseverity dynamic;<br \/>\n};<br \/>\n};<\/p>\n<p>zone &#8220;.&#8221; IN {<br \/>\ntype hint;<br \/>\nfile &#8220;named.ca&#8221;;<br \/>\n};<\/p>\n<p>zone &#8220;rmohan.net&#8221; IN {<br \/>\ntype master;<br \/>\nfile &#8220;\/var\/named\/rmohan.net.db&#8221;;<br \/>\nallow-update { none; };<br \/>\n};<\/p>\n<p>include &#8220;\/etc\/named.rfc1912.zones&#8221;;<br \/>\n2.2 Create a zone file for you domain \u201crmohan.net\u201d<\/p>\n<p># vim \/var\/named\/chroot\/var\/named\/rmohan.net.db<br \/>\nContent of zone file:<\/p>\n<p>; Zone file for rmohan.net<br \/>\n$TTL 14400<br \/>\n@ 86400 IN SOA ns1.rmohan.net. webmaster.rmohan.net. (<br \/>\n3215040200 ; serial, todays date+todays<br \/>\n86400 ; refresh, seconds<br \/>\n7200 ; retry, seconds<br \/>\n3600000 ; expire, seconds<br \/>\n86400 ) ; minimum, seconds<\/p>\n<p>rmohan.net. 86400 IN NS ns1.rmohan.net.<br \/>\nrmohan.net. 86400 IN NS ns2.rmohan.net.<br \/>\nrmohan.net. IN A 192.168.1.100<br \/>\nrmohan.net. IN MX 0 rmohan.net.<br \/>\nmail IN CNAME rmohan.net.<br \/>\nwww IN CNAME rmohan.net.<\/p>\n<p>&nbsp;<\/p>\n<p>2.3 Add more domains in dns server.<br \/>\nTo add more domains in dns, create zone files individually for all domain as above. After that add any entry for all zones in named.conf like below. Change rmohan.net with your domain name.<\/p>\n<p>zone &#8220;rmohan.net&#8221; IN {<br \/>\ntype master;<br \/>\nfile &#8220;\/var\/named\/rmohan.net.db&#8221;;<br \/>\nallow-update { none; };<br \/>\n};<br \/>\nStep 2.4: Start named service .<br \/>\nStart named (bind) service using following command and setup auto start on system boot.<\/p>\n<p># \/etc\/init.d\/named restart<br \/>\n# chkconfig named on<br \/>\nStep 3: Setup Slave (NS2) DNS Server<\/p>\n<p>At slave dns server you need to update named.conf file only. All zone files will automatically synced from master dns server. Any changes done on Master will reflect on slave after a specified time interval.<\/p>\n<p>3.1 Configure named.conf using below configuration<\/p>\n<p># vim \/var\/named\/chroot\/etc\/named.conf<br \/>\nContent of named.conf:<\/p>\n<p>\/\/ \/var\/named\/chroot\/etc\/named.conf<br \/>\noptions {<br \/>\nlisten-on port 53 { 127.0.0.1; 192.168.1.0\/24; };<br \/>\nlisten-on-v6 port 53 { ::1; };<br \/>\ndirectory &#8220;\/var\/named&#8221;;<br \/>\ndump-file &#8220;\/var\/named\/data\/cache_dump.db&#8221;;<br \/>\nstatistics-file &#8220;\/var\/named\/data\/named_stats.txt&#8221;;<br \/>\nmemstatistics-file &#8220;\/var\/named\/data\/named_mem_stats.txt&#8221;;<br \/>\nallow-query { localhost; 192.168.1.0\/24; };<br \/>\nrecursion yes;<\/p>\n<p>dnssec-enable yes;<br \/>\ndnssec-validation yes;<br \/>\ndnssec-lookaside auto;<\/p>\n<p>\/* Path to ISC DLV key *\/<br \/>\nbindkeys-file &#8220;\/etc\/named.iscdlv.key&#8221;;<\/p>\n<p>managed-keys-directory &#8220;\/var\/named\/dynamic&#8221;;<br \/>\n};<\/p>\n<p>logging {<br \/>\nchannel default_debug {<br \/>\nfile &#8220;data\/named.run&#8221;;<br \/>\nseverity dynamic;<br \/>\n};<br \/>\n};<\/p>\n<p>zone &#8220;.&#8221; IN {<br \/>\ntype hint;<br \/>\nfile &#8220;named.ca&#8221;;<br \/>\n};<\/p>\n<p>zone &#8220;rmohan.net&#8221; IN {<br \/>\ntype slave;<br \/>\nfile &#8220;slaves\/rmohan.net.db&#8221;;<br \/>\nmasters { 192.168.1.90; };<br \/>\n};<\/p>\n<p>include &#8220;\/etc\/named.rfc1912.zones&#8221;;<br \/>\nStep 3.2: Start named Service<br \/>\nStart named (bind) service using below command.<\/p>\n<p># \/etc\/init.d\/named restart<br \/>\n# chkconfig named on<br \/>\nAfter restarting named service, Check zone files on slave dns server at \/var\/named\/chroot\/var\/named\/slaves\/.<\/p>\n<p>Step 4: Finally Test Your DNS Setup.<\/p>\n<p>Query to your Master and Slave DNS Server directly using following commands, You will get the same resonse from both servers.<br \/>\nSyntax: nslookup &lt;domainname.com&gt; &lt;dns server name\/ip&gt;<\/p>\n<p>Query to Master DNS Server:<\/p>\n<p># nslookup rmohan.net 192.168.1.10<\/p>\n<p>Server: 192.168.1.10<br \/>\nAddress: 192.168.1.10#53<\/p>\n<p>Name: rmohan.net<br \/>\nAddress: 192.168.1.100<br \/>\nQuery to Slave DNS Server:<\/p>\n<p># nslookup rmohan.net 192.168.1.11<\/p>\n<p>Server: 192.168.1.11<br \/>\nAddress: 192.168.1.91#53<\/p>\n<p>Name: rmohan.net<br \/>\nAddress: 192.168.1.50<br \/>\nAbove outputs is showing that dns server has successfully resolved domain rmohan.net from master and slave dns servers.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Setup Master Slave DNS Server on CentOS 6 and RHEL<\/p>\n<p>The DNS ( Domain Name System ) is a distributed system, used for transalate domain names to IP and vice a versa. This article will help you to How to Setup Master Slave DNS Server on CentOS 6 and RHEL Systems.<\/p>\n<p>Network Scenario [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2118"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2118"}],"version-history":[{"count":4,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2118\/revisions"}],"predecessor-version":[{"id":2122,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2118\/revisions\/2122"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}