{"id":4483,"date":"2014-03-08T22:01:11","date_gmt":"2014-03-09T05:01:11","guid":{"rendered":"http:\/\/blog.networkpresence.co\/?p=4483"},"modified":"2014-11-01T16:42:57","modified_gmt":"2014-11-01T23:42:57","slug":"setup-bind-name-server-hosting-on-your-centos-vps","status":"publish","type":"post","link":"http:\/\/blog.networkpresence.co\/?p=4483","title":{"rendered":"Setup BIND Name Server Hosting on your CentOS VPS"},"content":{"rendered":"<p>Here&#8217;s how to use your dual IP address equipment Network Presence VPS running the CentOS flavour of Redhat Linux, to run your Name Servers (ns1 and ns2) for your own Domains.<\/p>\n<p>First, you need two separate live to the Internet IPv4 IP Addresses and if you&#8217;re VPS Plan is one of our popular Value VPS Plans, then you only have a single IP address to start. So our &#8220;<a href=\"http:\/\/www.networkpresence.com.au\/professional-services\/extra-ip-address-detail.html\">Extra IP Address for your VPS<\/a>&#8221; Professional Services product provides you with another IP address that can be configured to your CentOS VPS.<\/p>\n<p>If you need to configure another IP address to your CentOS VPS, then replace X.X.X.X and Y with details supplied by us in the following shell command extract (run as the &#8216;root&#8217; user when logged into your VPS by SSH client) :<\/p>\n<p><code># cat < EOF > \/etc\/sysconfig\/network-scripts\/ifcfg-eth0:0<br \/>\nDEVICE=\"eth0:0\"<br \/>\nBOOTPROTO=\"static\"<br \/>\nIPADDR=X.X.X.X<br \/>\nNETMASK=255.255.255.Y<br \/>\nONBOOT=\"yes\"<br \/>\nEOF<\/p>\n<p>ifup eth0:0   ## or reboot now..<\/code><\/p>\n<p>Then with your dual IP Addresses running on your VPS, you can now install the BIND\/named Name Server packages for CentOS with:<\/p>\n<p><code>yum -y install bind bind-chroot<\/code><\/p>\n<p>This just installs the software, but doesn&#8217;t configure it in any way and you next need to populate the various files that BIND<br \/>\nneeds in the &#8216;chroot&#8217; directory tree (<code>\/var\/named\/chroot\/<\/code>) to run and host your domain name(s).<\/p>\n<p>Like most RHEL-based RPMs and open-source software distributions, the bind Package has installed example and documentation files into <code>\/usr\/share\/doc\/bind-9.3.6\/sample\/<\/code> <\/p>\n<p>So now we copy relevant example files and then configure your local Name Server for your Domain name and the following creates a named.conf file for you in the &#8220;chroot&#8221; directory tree of the CentOS &#8220;bind-chroot&#8221; package. Please substitute YOURDOMAIN.CO for your full domain name.<\/p>\n<p><code># cat < EOF > \/var\/named\/chroot\/etc\/named.conf<br \/>\n\/\/<br \/>\n\/\/ named.conf<br \/>\n\/\/<br \/>\n\/\/ Provided by Red Hat bind package to configure the ISC BIND named(8) DNS<br \/>\n\/\/ server as a caching only nameserver (as a localhost DNS resolver only).<br \/>\n\/\/<br \/>\n\/\/ See \/usr\/share\/doc\/bind*\/sample\/ for example named configuration files.<br \/>\n\/\/<br \/>\noptions {<br \/>\n        listen-on port 53 { any; };<br \/>\n        listen-on-v6 port 53 { any; };<br \/>\n        directory       \"\/var\/named\";<br \/>\n        dump-file       \"\/var\/named\/data\/cache_dump.db\";<br \/>\n        statistics-file \"\/var\/named\/data\/named_stats.txt\";<br \/>\n        memstatistics-file \"\/var\/named\/data\/named_mem_stats.txt\";<br \/>\n        allow-query     { any; };<br \/>\n        recursion no;<br \/>\n        allow-recursion { none; };<br \/>\n\tallow-transfer {<br \/>\n\t\tlocalhost;<br \/>\n \t\tIP-ADDRESS-OF-YOUR-SECONDARY-NAME-SERVER;<br \/>\n \t};<br \/>\n};<br \/>\nlogging {<br \/>\n        channel default_debug {<br \/>\n                file \"data\/named.run\";<br \/>\n                severity dynamic;<br \/>\n        };<br \/>\n};<br \/>\nzone \".\" IN {<br \/>\n        type hint;<br \/>\n        file \"named.ca\";<br \/>\n};<br \/>\ninclude \"\/etc\/named.conf.local\";<br \/>\nEOF<\/code><\/p>\n<p>Now configure your \/etc\/named.conf.local, with a template looking like:<\/p>\n<p><code># cat < EOF > \/var\/named\/chroot\/etc\/named.conf.local<br \/>\nzone \"YOURDOMAIN.CO\" {<br \/>\n        type master;<br \/>\n        allow-transfer {IP-ADDRESS-OF-YOUR-SECONDARY-NAME-SERVER;}; \/\/ or \"allow-transfer {none;};\" if you don't want any Secondary Name Server Zone Transfers<br \/>\n        file \"\/var\/named\/YOURDOMAIN.CO\";<br \/>\n        allow-query { any; };<br \/>\n};<br \/>\nEOF<\/code><\/p>\n<p>If you have a separate Secondary Name Server, then its named.conf.local file would be (to be a &#8216;slave&#8217; Name Server from your Primary&#8217;s IP address, assuming that the Primary Name Server is on X.X.X.X and the Secondary is on IP addr Y.Y.Y.Y, being the above referenced &#8216;IP-ADDRESS-OF-YOUR-SECONDARY-NAME-SERVER&#8217;:<\/p>\n<p><code># cat < EOF > \/var\/named\/chroot\/etc\/named.conf.local<br \/>\nzone \"YOURDOMAIN.CO\" {<br \/>\n        type slave;<br \/>\n        masters { X.X.X.X; };<br \/>\n        file \"\/var\/named\/chroot\/var\/named\/YOURDOMAIN.CO\";<br \/>\n        allow-query { any; };<br \/>\n};<br \/>\nEOF<\/code><\/p>\n<p>Make sure that the running Name Server software will be able to read those files with commands like (as root):<\/p>\n<p><code>chgrp named \/var\/named\/chroot\/etc\/named.conf \/var\/named\/chroot\/etc\/named.conf.local<br \/>\nchmod g+r \/var\/named\/chroot\/etc\/named.conf \/var\/named\/chroot\/etc\/named.conf.local<\/code><\/p>\n<p>Last step in the setup is to create the &#8220;Zone Files&#8221; (the actual files containing your domain&#8217;s data or information) and continuing to use the template\/demo domain name of YOURDOMAIN.CO and your VPS IP Address of X.X.X.X, here&#8217;s a template Zone File for YOURDOMAIN.CO:<\/p>\n<p><code># cat < EOF > \/var\/named\/chroot\/var\/named\/YOURDOMAIN.CO<br \/>\n$ORIGIN .<br \/>\n$TTL 3600\t; 1 hour<br \/>\nYOURDOMAIN.CO\t\tIN SOA\tns1.YOURDOMAIN.CO. domain.YOURDOMAIN.CO. (<br \/>\n\t\t\t\t2014030100 ; serial<br \/>\n\t\t\t\t8640      ; refresh (.1 day)<br \/>\n\t\t\t\t360       ; retry (.1 hour)<br \/>\n\t\t\t\t259200    ; expire ((4 weeks 2 days)\/10)<br \/>\n\t\t\t\t60480     ; minimum (.01 week)<br \/>\n\t\t\t\t)<br \/>\n$TTL 36000\t; 10 hours<br \/>\n\t\t\tNS\tns1.YOURDOMAIN.CO.<br \/>\n\t\t\tNS\tns2.YOURDOMAIN.CO.<br \/>\n$TTL 360\t; .1 hour<br \/>\n\t\t\tMX\t10 mail.YOURDOMAIN.CO.<br \/>\n\t\t\tA\tX.X.X.X<br \/>\n$ORIGIN YOURDOMAIN.CO.<br \/>\n$TTL 3600\t; 1 hour<br \/>\nns1 \t\t\tA \tX.X.X.X<br \/>\nns2 \t\t\tA \tY.Y.Y.Y  \/\/ if you have a Secondary Name Server on Y.Y.Y.Y or use X.X.X.X again (not recommended really though)<br \/>\n;<br \/>\nwww\t\t\tA\tIP.ADDR.of.your.Web.Server<br \/>\nmail\t\t\tA\tIP.ADDR.of.your.Mail.Server;<br \/>\nEOF<\/code><\/p>\n<p>With the templates and filenames listed above updated for your actual domain names, you can now test that your configuration works with:<\/p>\n<p><code>service named configtest<\/code><\/p>\n<p>If all is &#8220;Ok&#8221; in that output, now start your Name Server with:<\/p>\n<p><code>service named start<\/code><\/p>\n<p>And make sure it&#8217;ll start at system bootup with:<\/p>\n<p><code>chkconfig named on<\/code><\/p>\n<p>That should do it, start testing with the &#8216;dig&#8217; commands, substituting your actual domain name with something like:<\/p>\n<p><code>dig YOURDOMAIN.CO @127.0.01 # to test from the host itself<\/code><\/p>\n<p>Or from a remote host with:<\/p>\n<p><code>dig YOURDOMAIN.CO @X.X.X.X  # IP address as listed above<\/code><\/p>\n<p>FYI and Network Presence customers are welcome to <a href=\"http:\/\/netpr.es\/contactus\">contact us<\/a> for help setting up their Name Servers, regards,<br \/>\nRichard.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s how to use your dual IP address equipment Network Presence VPS running the CentOS flavour of Redhat Linux, to run your Name Servers (ns1 and ns2) for your own Domains. First, you need two separate live to the Internet &hellip; <a href=\"http:\/\/blog.networkpresence.co\/?p=4483\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[240,241],"class_list":["post-4483","post","type-post","status-publish","format-standard","hentry","category-network-presence","tag-bind","tag-named"],"_links":{"self":[{"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/posts\/4483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4483"}],"version-history":[{"count":12,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/posts\/4483\/revisions"}],"predecessor-version":[{"id":5765,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/posts\/4483\/revisions\/5765"}],"wp:attachment":[{"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4483"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}