{"id":32,"date":"2014-07-08T04:19:00","date_gmt":"2014-07-08T04:19:00","guid":{"rendered":"http:\/\/389@jodohost.com\/\/blog\/"},"modified":"2023-01-05T16:16:02","modified_gmt":"2023-01-05T16:16:02","slug":"setup-dns-server-with-bind-command","status":"publish","type":"post","link":"http:\/\/www.jodohost.com\/blog\/index.php\/2014\/07\/08\/setup-dns-server-with-bind-command\/","title":{"rendered":"Setup DNS Server with BIND command"},"content":{"rendered":"<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p>We are going to setup and configure the BIND DNS Server on CentOS. We are going to configure it at the same VPS sever where our webserver is installed. This this may not be the most viable solution for managing large number of domains.<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<h2>\u2022 Our DNS VPS system Details<\/h2>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 <strong>DNS VPS Hostname:<\/strong> server1.example.com<br \/>o\u00a0\u00a0 <strong>DNS IP Address:<\/strong> 1.1.1.1<br \/>o\u00a0\u00a0 <strong>Domain to configure:<\/strong> domain1.com<br \/>o\u00a0\u00a0 <strong>Web server IP address:<\/strong> 2.2.2.2<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<h2>\u2022 Preparation<\/h2>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Make sure that your system is updated before proceeding with the installation:<\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 yum update \u2013y<\/strong><\/p>\n<p style=\"padding-left: 90px;\"><strong><br \/><\/strong><\/p>\n<h2>\u2022 BIND Installation<\/h2>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Now install the BIND and BIND Utilities packages:<\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 yum install bind bind-utils \u2013y<br \/><\/strong><\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Now open the BIND (named) configuration file and make few modifications.<\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 nano -w \/etc\/named.conf<br \/><\/strong><\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Sample \u2018<strong>\/etc\/named.conf<\/strong>\u2018 configuration file:<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<h6 style=\"padding-left: 60px;\">options {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 #listen-on port 53 { 127.0.0.1; };<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 listen-on-v6 port 53 { ::1; };<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 directory &#8220;\/var\/named&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 dump-file &#8220;\/var\/named\/data\/cache_dump.db&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 statistics-file &#8220;\/var\/named\/data\/named_stats.txt&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 memstatistics-file &#8220;\/var\/named\/data\/named_mem_stats.txt&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 allow-transfer { localhost; };<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 allow-query { any; };<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 recursion no;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 dnssec-enable yes;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 dnssec-validation yes;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 dnssec-lookaside auto;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 \/* Path to ISC DLV key *\/<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 bindkeys-file &#8220;\/etc\/named.iscdlv.key&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 managed-keys-directory &#8220;\/var\/named\/dynamic&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 };<\/p>\n<p>logging {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 channel default_debug {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 file &#8220;data\/named.run&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 severity dynamic;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 };<\/p>\n<p>};<\/p>\n<p>zone &#8220;.&#8221; IN {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 type hint;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 file &#8220;named.ca&#8221;;<br \/>};<\/p>\n<p>include &#8220;\/etc\/named.rfc1912.zones&#8221;;<br \/>include &#8220;\/etc\/named.root.key&#8221;;<\/h6>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 In the above sample configuration file listen-on has been commented to listen on all available interfaces. Recursion should be turned off to prevent your server from being abused in &#8220;reflection&#8221; DDoS attacks. The allow-transfer directive whitelists transfers to your secondary droplet&#8217;s IP. Furthermore, we have changed the allow-query directive to &#8220;any&#8221; in order to allow users proper access to hosted zones.<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 We have added a new zone for our domain, now add the following to your named.conf below the existing zones. And now our configuration file looks like this:<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<h6 style=\"padding-left: 60px;\">options {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 #listen-on port 53 { 127.0.0.1; };<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 listen-on-v6 port 53 { ::1; };<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 directory &#8220;\/var\/named&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 dump-file &#8220;\/var\/named\/data\/cache_dump.db&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 statistics-file &#8220;\/var\/named\/data\/named_stats.txt&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 memstatistics-file &#8220;\/var\/named\/data\/named_mem_stats.txt&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 allow-transfer { localhost; };<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 allow-query { any; };<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 recursion no;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 dnssec-enable yes;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 dnssec-validation yes;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 dnssec-lookaside auto;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 \/* Path to ISC DLV key *\/<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 bindkeys-file &#8220;\/etc\/named.iscdlv.key&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 managed-keys-directory &#8220;\/var\/named\/dynamic&#8221;;<br \/>};<\/p>\n<p>logging {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 channel default_debug {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 file &#8220;data\/named.run&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 severity dynamic;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 };<br \/>};<br \/>\u00a0<br \/>zone &#8220;.&#8221; IN {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 type hint;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 file &#8220;named.ca&#8221;;<br \/>};<\/p>\n<p>zone &#8220;domain1.com&#8221; IN {<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 type master;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 file &#8220;domain1.com.zone&#8221;;<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 allow-update { none; };<br \/>};<\/p>\n<p>include &#8220;\/etc\/named.rfc1912.zones&#8221;;<br \/>include &#8220;\/etc\/named.root.key&#8221;;<\/h6>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<h2><strong>\u2022\u00a0<\/strong>Configure BIND Zones<\/h2>\n<p style=\"padding-left: 30px;\"><strong><br \/><\/strong><\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Create the zone file, using the name you specified in the configuration above.<\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 nano -w \/var\/named\/domain1.com.zone<br \/><\/strong><\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Sample \u2018\/var\/named\/domain1.com.zone \u2018 configuration file:<\/p>\n<h6 style=\"padding-left: 60px;\"><strong><br \/><\/strong>$TTL 86400<br \/>@ IN SOA ns1.domain1.com. root.domain1.com. (<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 2013042201 ;Serial<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 3600 ;Refresh<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 1800 ;Retry<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 604800 ;Expire<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 86400 ;Minimum TTL<br \/>)<\/p>\n<p>; Specify our two nameservers<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 IN NS ns1.domain1.com.<br \/>; Resolve nameserver hostnames to IP, replace with your two droplet IP addresses.<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 ns1 IN A 2.2.2.2<\/p>\n<p>; Define hostname -> IP pairs which you wish to resolve<br \/>@ IN A 2.2.2.2<br \/>www IN A 2.2.2.2<\/h6>\n<p style=\"padding-left: 30px;\"><strong><br \/><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><br \/><\/strong><\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Start named for the first time. This may take several minutes while named generates the rndc.key file, which only occurs on first execution.<\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 service named restart<\/strong><\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 When the named has started successfully, we would like to ensure that it is enabled as a startup service, by running the following:<\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 chkconfig named on<br \/><\/strong><\/p>\n<p style=\"padding-left: 60px;\"><strong><br \/><\/strong><\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Now we have a fully operational primary nameserver. You can verify that BIND is working correctly by running the following command, replacing 1.1.1.1 with the IP of your first droplet.<\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 dig @1.1.1.1 mydomain.com<br \/><\/strong><\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 After any changes you make to the master zone files, you will need to instruct BIND to reload. To reload the zone files, we need to run the following command on the master nameserver:<\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 rndc reload<br \/><\/strong><\/p>\n<p style=\"padding-left: 60px;\">\u00a0<\/p>\n<p style=\"padding-left: 60px;\">\u00a0<\/p>\n<h2>\u2022 BIND in a chroot environment<\/h2>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 It is generally advised to install the additional package &#8220;bind-chroot&#8221; which will drop the privileges of BIND into a chroot environment. If you&#8217;d like to enable this feature for the added security which it provides, you can do the following:<\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 yum install bind-chroot \u2013y<\/strong><\/p>\n<p style=\"padding-left: 60px;\"><strong>\u00a7\u00a0 service named restart<\/strong><\/p>\n<p style=\"padding-left: 60px;\"><strong><br \/><\/strong><\/p>\n<p style=\"padding-left: 60px;\"><strong><br \/><\/strong><\/p>\n<h2>\u2022 Configuring child name server<\/h2>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 We need to configure child name server to make it available over the internet for everyone.<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Login into domain control panel from http:\/\/store.domainsgofast.com\/customer<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Search the order into control panel- domain\u00a0 and click on the domain name<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 On appeared page you will be able to see Child Name Server section, click on the same.<\/p>\n<p style=\"padding-left: 30px;\">o\u00a0\u00a0 Fill the prefix like- ns1, in hostname section and IP in second section and click on submit.<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">\n<div class=\"pivotx-wrapper\"><a href='http:\/\/www.jodohost.com\/blog\/images\/2014-07\/a1orders-child-name-server_2.jpg' class=\"thickbox\" title=\"Creating child nameserver\" rel=\"entry-0\" ><img decoding=\"async\" src=\"http:\/\/www.jodohost.com\/blog\/images\/2014-07\/a1orders-child-name-server_2.thumb.jpg\" alt=\"Creating child nameserver\" title=\"Creating child nameserver\" class='pivotx-popupimage'\/><\/a><\/div>\n<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<div class=\"pivotx-wrapper\"><a href='http:\/\/www.jodohost.com\/blog\/images\/2014-07\/a1orders-name-server.jpg' class=\"thickbox\" title=\"Creating child nameserver 2\" rel=\"entry-0\" ><img decoding=\"async\" src=\"http:\/\/www.jodohost.com\/blog\/images\/2014-07\/a1orders-name-server.thumb.jpg\" alt=\"Creating child nameserver 2\" title=\"Creating child nameserver 2\" class='pivotx-popupimage'\/><\/a><\/div>\n<\/p>\n<p style=\"padding-left: 30px;\">\u00a0<\/p>\n<p><strong>Here we are done and now we have configured a working DNS server.<\/strong><\/p>\n<p style=\"padding-left: 60px;\"><strong><br \/><\/strong><\/p>\n<p style=\"padding-left: 60px;\"><strong><br \/><\/strong><\/p>\n<p> ]]><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 We are going to setup and configure the BIND DNS Server on CentOS. We are going to configure it at the same VPS sever where our webserver is installed. This this may not be the most viable solution for managing large number of domains. \u00a0 \u00a0 \u2022 Our DNS VPS system Details \u00a0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/32"}],"collection":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":1,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":326,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/32\/revisions\/326"}],"wp:attachment":[{"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jodohost.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}