{"id":1867,"date":"2013-02-17T23:55:46","date_gmt":"2013-02-17T15:55:46","guid":{"rendered":"http:\/\/rmohan.com\/?p=1867"},"modified":"2013-02-17T23:59:44","modified_gmt":"2013-02-17T15:59:44","slug":"bind-chroot-2","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1867","title":{"rendered":"Bind Chroot"},"content":{"rendered":"<p>Setup DNS Server step by step in CentOS 6.3 \/ RHEL 6.3<\/p>\n<p>DNS (Domain Name System) is the core component of network infrastructure. The DNS service resolves hostname into ip address and vice versa. For example if we type http:\/\/www.rmohan.com in browser, the DNS server translates the domain name into its corresponding ip address. So it makes us easy to remember the domain names instead of its ip address.<\/p>\n<p>DNS Server Installation in CentOS 6.3:<\/p>\n<p>This how-to tutorial will shows you how to install and configure DNS server. In this scenario my dns server FQDN (Fully Qualified Domain Name) and <br \/>ip-address are webserver.rmohan.com and 192.168.1.100 respectively. The steps provided here are tested in CentOS 6.3, but it should work in RHEL 6.x(x stands for version) and Scientific Linux 6.x too.<\/p>\n<p>Prerequisites:<\/p>\n<p>Before proceed, check the following properly.<\/p>\n<p>1. Check FQDN (Fully Qualified Name) of the server.<\/p>\n<p>[root@webserver ~]# hostname<br \/> webserver.rmohan.com<br \/>2. Check IP Address of the Server.<\/p>\n<p>[root@webserver ~]# ifconfig eth0<br \/>eth0 Link encap:Ethernet HWaddr 08:00:27:1B:84:3A <br \/> inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0<br \/> inet6 addr: fe80::a00:27ff:fe1b:843a\/64 Scope:Link<br \/> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1<br \/> RX packets:7785 errors:0 dropped:0 overruns:0 frame:0<br \/> TX packets:3635 errors:0 dropped:0 overruns:0 carrier:0<br \/> collisions:0 txqueuelen:1000 <br \/> RX bytes:729396 (712.3 KiB) TX bytes:461240 (450.4 KiB)<br \/>3. Enter the resolver IP (DNS Server IP i.e 192.168.1.100 in our example) in \/etc\/resolv.conf file.<\/p>\n<p>[root@webserver ~]# nano \/etc\/resolv.conf<br \/> # Generated by NetworkManager<br \/>search rmohan.com<br \/>nameserver 192.168.1.100<br \/>4. Disable Firewall.<\/p>\n<p>[root@webserver ~]# service iptables stop<br \/>[root@webserver ~]# chkconfig iptables off<br \/>[root@webserver ~]# service ip6tables stop<br \/>[root@webserver ~]# chkconfig ip6tables off<br \/>5.Disable selinux.<\/p>\n<p>Set SELINUX=disabled to disable the Selinux in the \/etc\/selinux\/config file..<br \/>[root@webserver ~]# nano \/etc\/selinux\/config<br \/># This file controls the state of SELinux on the system.<br \/># SELINUX= can take one of these three values:<br \/># enforcing &#8211; SELinux security policy is enforced.<br \/># permissive &#8211; SELinux prints warnings instead of enforcing.<br \/># disabled &#8211; No SELinux policy is loaded.<br \/>SELINUX=disabled<br \/># SELINUXTYPE= can take one of these two values:<br \/># targeted &#8211; Targeted processes are protected,<br \/># mls &#8211; Multi Level Security protection.<br \/>SELINUXTYPE=targeted<br \/>Reboot the server to save the changes.<\/p>\n<p>6.Check Firewall and Selinux Status:<\/p>\n<p>[root@webserver ~]# service iptables status<br \/>iptables: Firewall is not running.<br \/>[root@webserver ~]# service ip6tables status<br \/>ip6tables: Firewall is not running.<br \/>[root@webserver ~]# sestatus <br \/>SELinux status: disabled<br \/>Well, all the services are disabled now.<br \/>Install bind9 package:<\/p>\n<p>[root@webserver ~]# yum install bind*<br \/>Loaded plugins: fastestmirror<br \/>Loading mirror speeds from cached hostfile<br \/>localrepo | 1.3 kB 00:00 &#8230; <br \/>Setting up Install Process<br \/>Resolving Dependencies<br \/>&#8211;&gt; Running transaction check<br \/>&#8212;&gt; Package bind.i686 32:9.8.2-0.10.rc1.el6 will be installed<br \/>&#8211;&gt; Processing Dependency: portreserve for package: 32:bind-9.8.2-0.10.rc1.el6.i686<br \/>&#8212;&gt; Package bind-chroot.i686 32:9.8.2-0.10.rc1.el6 will be installed<br \/>&#8212;&gt; Package bind-devel.i686 32:9.8.2-0.10.rc1.el6 will be installed<br \/>&#8212;&gt; Package bind-dyndb-ldap.i686 0:1.1.0-0.9.b1.el6 will be installed<br \/>&#8212;&gt; Package bind-libs.i686 32:9.8.2-0.10.rc1.el6 will be installed<br \/>&#8212;&gt; Package bind-sdb.i686 32:9.8.2-0.10.rc1.el6 will be installed<br \/>&#8211;&gt; Processing Dependency: libpq.so.5 for package: 32:bind-sdb-9.8.2-0.10.rc1.el6.i686<br \/>&#8212;&gt; Package bind-utils.i686 32:9.8.2-0.10.rc1.el6 will be installed<br \/>&#8211;&gt; Running transaction check<br \/>&#8212;&gt; Package portreserve.i686 0:0.0.4-9.el6 will be installed<br \/>&#8212;&gt; Package postgresql-libs.i686 0:8.4.11-1.el6_2 will be installed<br \/>&#8211;&gt; Finished Dependency Resolution<br \/>Dependencies Resolved<br \/>===================================================<br \/> Package Arch Version Repository Size<br \/>===================================================<br \/>Installing:<br \/> bind i686 32:9.8.2-0.10.rc1.el6 localrepo 4.0 M<br \/> bind-chroot i686 32:9.8.2-0.10.rc1.el6 localrepo 70 k<br \/> bind-devel i686 32:9.8.2-0.10.rc1.el6 localrepo 375 k<br \/> bind-dyndb-ldap i686 1.1.0-0.9.b1.el6 localrepo 63 k<br \/> bind-libs i686 32:9.8.2-0.10.rc1.el6 localrepo 881 k<br \/> bind-sdb i686 32:9.8.2-0.10.rc1.el6 localrepo 305 k<br \/> bind-utils i686 32:9.8.2-0.10.rc1.el6 localrepo 180 k<br \/>Installing for dependencies:<br \/> portreserve i686 0.0.4-9.el6 localrepo 22 k<br \/> postgresql-libs i686 8.4.11-1.el6_2 localrepo 201 k<br \/>Transaction Summary<br \/>===================================================<br \/>Install 9 Package(s)<br \/>Total download size: 6.0 M<br \/>Installed size: 13 M<br \/>Is this ok [y\/N]: y<br \/>Downloading Packages:<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>Total 16 MB\/s | 6.0 MB 00:00 <br \/>Running rpm_check_debug<br \/>Running Transaction Test<br \/>Transaction Test Succeeded<br \/>Running Transaction<br \/>Warning: RPMDB altered outside of yum.<br \/> Installing : 32:bind-libs-9.8.2-0.10.rc1.el6.i686 1\/9 <br \/> Installing : portreserve-0.0.4-9.el6.i686 2\/9 <br \/> Installing : 32:bind-9.8.2-0.10.rc1.el6.i686 3\/9 <br \/> Installing : postgresql-libs-8.4.11-1.el6_2.i686 4\/9 <br \/> Installing : 32:bind-chroot-9.8.2-0.10.rc1.el6.i686 5\/9 <br \/> Installing : 32:bind-devel-9.8.2-0.10.rc1.el6.i686 6\/9 <br \/> Installing : 32:bind-sdb-9.8.2-0.10.rc1.el6.i686 7\/9 <br \/> Installing : bind-dyndb-ldap-1.1.0-0.9.b1.el6.i686 8\/9 <br \/> Installing : 32:bind-utils-9.8.2-0.10.rc1.el6.i686 9\/9 <br \/> Verifying : 32:bind-utils-9.8.2-0.10.rc1.el6.i686 1\/9 <br \/> Verifying : 32:bind-chroot-9.8.2-0.10.rc1.el6.i686 2\/9 <br \/> Verifying : 32:bind-devel-9.8.2-0.10.rc1.el6.i686 3\/9 <br \/> Verifying : postgresql-libs-8.4.11-1.el6_2.i686 4\/9 <br \/> Verifying : 32:bind-sdb-9.8.2-0.10.rc1.el6.i686 5\/9 <br \/> Verifying : portreserve-0.0.4-9.el6.i686 6\/9 <br \/> Verifying : 32:bind-9.8.2-0.10.rc1.el6.i686 7\/9 <br \/> Verifying : 32:bind-libs-9.8.2-0.10.rc1.el6.i686 8\/9 <br \/> Verifying : bind-dyndb-ldap-1.1.0-0.9.b1.el6.i686 9\/9 <br \/>Installed:<br \/> bind.i686 32:9.8.2-0.10.rc1.el6 bind-chroot.i686 32:9.8.2-0.10.rc1.el6 <br \/> bind-devel.i686 32:9.8.2-0.10.rc1.el6 bind-dyndb-ldap.i686 0:1.1.0-0.9.b1.el6<br \/> bind-libs.i686 32:9.8.2-0.10.rc1.el6 bind-sdb.i686 32:9.8.2-0.10.rc1.el6 <br \/> bind-utils.i686 32:9.8.2-0.10.rc1.el6<br \/>Dependency Installed:<br \/> portreserve.i686 0:0.0.4-9.el6 postgresql-libs.i686 0:8.4.11-1.el6_2 <br \/>Complete!<br \/>Configuration:<\/p>\n<p>The main configuration of the DNS will look like below. Edit and add the entries below which are marked as bold in this configuration files.<\/p>\n<p>[root@webserver ~]# nano \/etc\/named.conf <br \/>\/\/<br \/>\/\/ named.conf<br \/>\/\/<br \/>\/\/ Provided by Red Hat bind package to configure the ISC BIND named(8) DNS<br \/>\/\/ server as a caching only nameserver (as a localhost DNS resolver only).<br \/>\/\/<br \/>\/\/ See \/usr\/share\/doc\/bind*\/sample\/ for example named configuration files.<br \/>\/\/<br \/>options {<br \/> listen-on port 53 { 127.0.0.1; 192.168.1.100; };<br \/> listen-on-v6 port 53 { ::1; };<br \/> directory &#8220;\/var\/named&#8221;;<br \/> dump-file &#8220;\/var\/named\/data\/cache_dump.db&#8221;;<br \/> statistics-file &#8220;\/var\/named\/data\/named_stats.txt&#8221;;<br \/> memstatistics-file &#8220;\/var\/named\/data\/named_mem_stats.txt&#8221;;<br \/> allow-query { localhost; 192.168.1.0\/24; };<br \/> recursion yes;<br \/> dnssec-enable yes;<br \/> dnssec-validation yes;<br \/> dnssec-lookaside auto;<br \/> \/* Path to ISC DLV key *\/<br \/> bindkeys-file &#8220;\/etc\/named.iscdlv.key&#8221;;<br \/> managed-keys-directory &#8220;\/var\/named\/dynamic&#8221;;<br \/>};<br \/>logging {<br \/> channel default_debug {<br \/> file &#8220;data\/named.run&#8221;;<br \/> severity dynamic;<br \/> };<br \/>};<br \/>zone &#8220;.&#8221; IN {<br \/> type hint;<br \/> file &#8220;named.ca&#8221;;<br \/>};<br \/>zone &#8220;rmohan.com&#8221; IN {<br \/> type master;<br \/> file &#8220;fwd.rmohan.com&#8221;;<br \/> allow-update { none; };<br \/>};<br \/>zone &#8220;1.168.192.in-addr.arpa&#8221; IN {<br \/> type master;<br \/> file &#8220;rev.rmohan.com&#8221;;<br \/> allow-update { none; };<br \/>};<br \/>include &#8220;\/etc\/named.rfc1912.zones&#8221;;<br \/>include &#8220;\/etc\/named.root.key&#8221;;<br \/>Create Zone files:<\/p>\n<p>Now we should create forward and reverse zone files which we mentioned in the \/etc\/named.conf file.<br \/>Create Forward Zone:<\/p>\n<p>Create fwd.rmohan.com file in the \/var\/named directory and add the entries for forward zone as shown below.<\/p>\n<p>[root@webserver ~]# nano \/var\/named\/fwd.rmohan.com<br \/>$TTL 86400<br \/>@ IN SOA webserver.rmohan.com. root.rmohan.com. (<br \/> 2011071001 ;Serial<br \/> 3600 ;Refresh<br \/> 1800 ;Retry<br \/> 604800 ;Expire<br \/> 86400 ;Minimum TTL<br \/>)<br \/> IN NS webserver.rmohan.com.<br \/> IN A 192.168.1.100<br \/>webserver IN A 192.168.1.100<br \/>Save and exit the file by pressing the keys CTRL+O and CTRL+X.<\/p>\n<p>Create Reverse Zone:<\/p>\n<p>Create rev.rmohan.com file in the \/var\/named directory and add the entries for reverse zone as shown below.<\/p>\n<p>[root@webserver ~]# nano \/var\/named\/rev.rmohan.com<br \/>$TTL 86400<br \/>@ IN SOA webserver.rmohan.com. root.rmohan.com. (<br \/> 2011071001 ;Serial<br \/> 3600 ;Refresh<br \/> 1800 ;Retry<br \/> 604800 ;Expire<br \/> 86400 ;Minimum TTL<br \/>)<br \/> IN NS webserver.rmohan.com.<br \/> IN PTR rmohan.com.<br \/> IN A 255.255.255.0<br \/>100 IN PTR webserver.rmohan.com.<br \/>Save and exit by pressing the keys CTRL+O and CTRL+X.<\/p>\n<p>Start the bind service.<\/p>\n<p>[root@webserver ~]# service named start<br \/>Generating \/etc\/rndc.key: [ OK ]<br \/>Starting named: [ OK ]<br \/>[root@webserver ~]# chkconfig named on<br \/>Test DNS Server:<\/p>\n<p>[root@webserver ~]# dig webserver.rmohan.com<br \/>; &lt;&lt;&gt;&gt; DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 &lt;&lt;&gt;&gt; webserver.rmohan.com<br \/>;; global options: +cmd<br \/>;; Got answer:<br \/>;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 217<br \/>;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0<br \/>;; QUESTION SECTION:<br \/>;webserver.rmohan.com. IN A<br \/>;; ANSWER SECTION:<br \/>webserver.rmohan.com. 86400 IN A 192.168.1.100<br \/>;; AUTHORITY SECTION:<br \/>rmohan.com. 86400 IN NS webserver.rmohan.com.<br \/>;; Query time: 3 msec<br \/>;; SERVER: 192.168.1.100#53(192.168.1.100)<br \/>;; WHEN: Fri Jan 25 16:50:45 2013<br \/>;; MSG SIZE rcvd: 72<br \/>[root@webserver ~]# dig -x 192.168.1.100<br \/>; &lt;&lt;&gt;&gt; DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 &lt;&lt;&gt;&gt; -x 192.168.1.100<br \/>;; global options: +cmd<br \/>;; Got answer:<br \/>;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 3272<br \/>;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1<br \/>;; QUESTION SECTION:<br \/>;100.1.168.192.in-addr.arpa. IN PTR<br \/>;; ANSWER SECTION:<br \/>100.1.168.192.in-addr.arpa. 86400 IN PTR webserver.rmohan.com.<br \/>;; AUTHORITY SECTION:<br \/>1.168.192.in-addr.arpa. 86400 IN NS webserver.rmohan.com.<br \/>;; ADDITIONAL SECTION:<br \/>webserver.rmohan.com. 86400 IN A 192.168.1.100<br \/>;; Query time: 4 msec<br \/>;; SERVER: 192.168.1.100#53(192.168.1.100)<br \/>;; WHEN: Fri Jan 25 16:52:13 2013<br \/>;; MSG SIZE rcvd: 112<br \/>If you get all the four sections QUESTION, ANSWER, AUTHORITY, ADDITIONAL as 1, you\u2019re done. Otherwise check the steps again for any mistakes.<\/p>\n<p>Thats it. Have a good day!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setup DNS Server step by step in CentOS 6.3 \/ RHEL 6.3<\/p>\n<p>DNS (Domain Name System) is the core component of network infrastructure. The DNS service resolves hostname into ip address and vice versa. For example if we type http:\/\/www.rmohan.com in browser, the DNS server translates the domain name into its corresponding ip address. So [&#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\/1867"}],"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=1867"}],"version-history":[{"count":3,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1867\/revisions"}],"predecessor-version":[{"id":1872,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1867\/revisions\/1872"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}