{"id":355,"date":"2011-02-25T00:25:56","date_gmt":"2011-02-24T16:25:56","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=355"},"modified":"2023-06-23T11:35:54","modified_gmt":"2023-06-23T11:35:54","slug":"how-to-configure-the-linux-bind-dns-server","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-configure-the-linux-bind-dns-server\/","title":{"rendered":"How to Configure the Linux Bind DNS Server"},"content":{"rendered":"<p>BIND (Berkeley Internet Name Domain) is a widely used DNS server that plays a crucial role in the majority of name-serving machines on both intranets and the Internet.<\/p>\n<p>This guide will walk you through the process of setting up an intranet DNS configuration using BIND on Linux, providing you with a fundamental understanding of Linux BIND DNS configuration.<\/p>\n<p>Before we proceed, it&#8217;s important to note that this tutorial assumes you have already installed the Bind DNS server on your CentOS or RHEL system. If you haven&#8217;t done so, you can follow this guide on <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-dedicated-server-hosting\/\">how to install Bind DNS server on CentOS and RHEL<\/a>.<\/p>\n<h2>Configuring the BIND DNS Server<\/h2>\n<p>To begin, navigate to the directory where the BIND configuration file is located:<\/p>\n<pre>\r\n[root@server ~]# cd \/var\/named\/chroot\/etc\r\n<\/pre>\n<p>Open the configuration file named.conf:<\/p>\n<pre>\r\n[root@server etc]# vi named.conf\r\n<\/pre>\n<p>In the configuration file, you will need to specify the directory, pid-file, and forwarders. Here&#8217;s an example of what your configuration might look like:<\/p>\n<pre>options {\r\n        directory \"\/etc\";\r\n        pid-file \"\/var\/run\/named\/named.pid\";\r\n\tforwarders {\r\n\t\t202.188.0.133;\r\n\t\t202.188.1.5;\r\n\t\t};\r\n        };\r\n\r\nzone \"myintranet.local\" {\r\n        type master;\r\n        file \"\/var\/named\/myintranet.local.hosts\";\r\n        };\r\nzone \"2.168.192.in-addr.arpa\" {\r\n        type master;\r\n        notify no;\r\n        file \"\/var\/named\/db.192\";\r\n};\r\n<\/pre>\n<p>Next, you will need to define the zones for your intranet. In this example, we&#8217;re setting up a zone for &#8220;myintranet.local&#8221; and a reverse lookup zone for &#8220;2.168.192.in-addr.arpa&#8221;. The configuration should look something like this:<\/p>\n<pre>\r\nzone \"myintranet.local\" {\r\n type master;\r\n file \"\/var\/named\/myintranet.local.hosts\";\r\n};\r\n\r\nzone \"2.168.192.in-addr.arpa\" {\r\n type master;\r\n notify no;\r\n file \"\/var\/named\/db.192\";\r\n};\r\n<\/pre>\n<p>After saving and closing the named.conf file, navigate to the directory where the zone files are located:<\/p>\n<pre>\r\n[root@server ~]# cd \/var\/named\/chroot\/var\/named\r\n<\/pre>\n<p>Open the zone file for &#8220;myintranet.local&#8221;:<\/p>\n<pre>\r\n[root@server named]# vi myintranet.local.hosts\r\n<\/pre>\n<p>In the zone file, you will need to specify the SOA (Start of Authority) record, NS (Name Server) record, and A (Address) records. Here&#8217;s an example of what your zone file might look like:<\/p>\n<pre>$ttl 38400\r\nmyintranet.local.\tIN\tSOA\tns.myintranet.local. root.myintranet.local. (\r\n\t\t\t1298557357\r\n\t\t\t10800\r\n\t\t\t3600\r\n\t\t\t604800\r\n\t\t\t38400 )\r\nmyintranet.local.       IN      NS      ns.myintranet.local.\r\n\r\nns.myintranet.local.\tIN\tA\t192.168.2.5\r\nwww.myintranet.local.\tIN\tA\t192.168.2.5\r\n<\/pre>\n<p>Next, open the reverse lookup zone file:<\/p>\n<pre>\r\n[root@server named]# vi db.192\r\n<\/pre>\n<p>In the reverse lookup zone file, you will need to specify the SOA record, NS record, and PTR (Pointer) records. Here&#8217;s an example of what your reverse lookup zone file might look like:<\/p>\n<pre>$ttl 38400\r\n2.168.192.in-addr.arpa.\tIN\tSOA\tns.myintranet.local. root.myintranet.local. (\r\n\t\t\t1298557341\r\n\t\t\t10800\r\n\t\t\t3600\r\n\t\t\t604800\r\n\t\t\t38400 )\r\n@     IN      NS      ns.myintranet.local.\r\n5.2.168.192.in-addr.arpa.\tIN\tPTR\tns.myintranet.local.\r\n<\/pre>\n<h2>Starting the BIND DNS Server<\/h2>\n<p>After you&#8217;ve finished configuring the BIND DNS server, you can start the server with the following command:<\/p>\n<pre>\r\n[root@server \/]# \/etc\/rc.d\/init.d\/named start\r\n<\/pre>\n<p>You should see a message indicating that the server has started successfully:<\/p>\n<pre>\r\nStarting named: [ OK ]\r\n<\/pre>\n<p>To ensure that the BIND DNS server starts automatically at boot time, use the following command:<\/p>\n<pre>\r\n[root@server \/]# chkconfig named on\r\n<\/pre>\n<h2>Testing the DNS Server<\/h2>\n<p>To verify that your DNS server is working correctly, you can use the nslookup command. However, before you do this, make sure that you have configured your DNS to 192.168.2.5.<\/p>\n<p>Here&#8217;s an example of a successful nslookup result:<\/p>\n<pre>\r\nIP Address. . . . . . . . . . . . : 192.168.2.2\r\nSubnet Mask . . . . . . . . . . . : 255.255.255.0\r\nDefault Gateway . . . . . . . . . : 192.168.2.1\r\nDNS Servers . . . . . . . . . . . : 192.168.2.5\r\n\r\nC:\\&gt;nslookup\r\nDefault Server:  ns.myintranet.local\r\nAddress:  192.168.2.5\r\n\r\n&gt; myintranet.local\r\nServer:  ns.myintranet.local\r\nAddress:  192.168.2.5\r\n\r\nName:    myintranet.local\r\n\r\n&gt; www.myintranet.local\r\nServer:  ns.myintranet.local\r\nAddress:  192.168.2.5\r\n\r\nName:    www.myintranet.local\r\nAddress:  192.168.2.5\r\n\r\n&gt; ns.myintranet.local\r\nServer:  ns.myintranet.local\r\nAddress:  192.168.2.5\r\n\r\nName:    ns.myintranet.local\r\nAddress:  192.168.2.5\r\n\r\n&gt; exit\r\n<\/pre>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">cd<\/span> \u2013 Changes the current directory.<\/li>\n<li><span class=\"fw-bold\">vi<\/span> \u2013 Opens a file in the vi text editor.<\/li>\n<li><span class=\"fw-bold\">\/etc\/rc.d\/init.d\/named start<\/span> \u2013 Starts the BIND DNS server.<\/li>\n<li><span class=\"fw-bold\">chkconfig named on<\/span> \u2013 Ensures that the BIND DNS server starts automatically at boot time.<\/li>\n<li><span class=\"fw-bold\">nslookup<\/span> \u2013 Tests the DNS server.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Setting up and configuring a BIND DNS server on Linux can seem like a daunting task, but with the right guidance and understanding of the key concepts, it&#8217;s a task that can be accomplished by any dedicated server or VPS server administrator. This tutorial has provided a step-by-step guide to configuring a BIND DNS server for an intranet, including setting up the main configuration file, defining zones, and testing the server.<\/p>\n<p>Remember, the key to successful server administration is understanding the underlying concepts and being able to apply them to your specific needs. Whether you&#8217;re working with a dedicated server, a VPS server, or even a cloud hosting or shared hosting environment, the principles remain the same.<\/p>\n<p>For more in-depth information about web servers, you can check out these articles on the <a href=\"https:\/\/webhostinggeeks.com\/best\/web-server\/\">best web servers<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/apache-http-server-explained\/\">Apache<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/nginx-server-explained\/\">Nginx<\/a>, and <a href=\"https:\/\/webhostinggeeks.com\/blog\/litespeed-web-server-explained\/\">LiteSpeed<\/a>.<\/p>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is BIND in Linux?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">BIND, or Berkeley Internet Name Domain, is a widely used DNS server that plays a crucial role in the majority of name-serving machines on both intranets and the Internet. It is used to translate human-readable domain names into machine-readable IP addresses and vice versa.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the purpose of the named.conf file?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The named.conf file is the main configuration file for the BIND DNS server. It contains settings such as the location ofthe zone files, the types of zones, the IP addresses of forwarders, and other options that control the behavior of the BIND server.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is a zone file in DNS?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">A zone file in DNS is a text file that contains the details of a DNS zone &#8211; a portion of the DNS namespace. It includes records for each domain within the zone, such as A (Address) records, NS (Name Server) records, and PTR (Pointer) records.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the purpose of the nslookup command?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The nslookup command is used to query DNS servers to find the IP address associated with a domain name, or vice versa. It&#8217;s a useful tool for testing and troubleshooting DNS servers.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What does the chkconfig command do?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The chkconfig command is used in Linux to manage services and ensure they start automatically at boot time. In the context of this tutorial, the command &#8220;chkconfig named on&#8221; ensures that the BIND DNS server starts automatically whenever the system boots up.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>BIND (Berkeley Internet Name Domain) is a widely used DNS server that plays a crucial role in the majority of name-serving machines on both intranets and the Internet. This guide&#8230;<\/p>\n","protected":false},"author":6,"featured_media":323,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[996],"tags":[1228,1337,1536],"class_list":["post-355","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-bind","tag-dns","tag-linux"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=355"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/355\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/323"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}