{"id":15,"date":"2024-12-19T08:37:19","date_gmt":"2024-12-19T08:37:19","guid":{"rendered":"https:\/\/paessens.org\/blog\/?p=15"},"modified":"2026-01-21T08:44:48","modified_gmt":"2026-01-21T07:44:48","slug":"how-to-set-up-a-primary-dns-server-with-bind-on-centos-9","status":"publish","type":"post","link":"https:\/\/paessens.org\/blog\/index.php\/2024\/12\/19\/how-to-set-up-a-primary-dns-server-with-bind-on-centos-9\/","title":{"rendered":"How to Set Up a Primary DNS Server with BIND on CentOS 9"},"content":{"rendered":"\n<p class=\"is-style-text-subtitle wp-block-paragraph\">Prerequisites<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>running server with CentOS 9<\/li>\n\n\n\n<li>root or sudo privileges<\/li>\n\n\n\n<li>An available domain name to configure<\/li>\n<\/ul>\n\n\n\n<p class=\"is-style-default wp-block-paragraph\">Step 1: Installing BIND<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As always start with updating the system:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>sudo yum update -y<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once updated and reboot, install BIND and its utilties<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>sudo yum install bind bind-utils -y<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Edit the main BIND configuration file named <code>named.conf<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/etc\/named.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Inside the configuration file, set the options for your DNS server. Below is a basic configuration snippet:<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"border-style:none;border-width:0px\"><code>options {\n        listen-on port 53 { any; };\n        \/\/listen-on-v6 port 53 { ::1; };\n        directory       \"\/var\/named\";\n        dump-file       \"\/var\/named\/data\/cache_dump.db\";\n        statistics-file \"\/var\/named\/data\/named_stats.txt\";\n        memstatistics-file \"\/var\/named\/data\/named_mem_stats.txt\";\n        secroots-file   \"\/var\/named\/data\/named.secroots\";\n        recursing-file  \"\/var\/named\/data\/named.recursing\";\n        allow-query     { any; };\n\n        recursion no;\n\n        dnssec-validation yes;\n\n        managed-keys-directory \"\/var\/named\/dynamic\";\n        geoip-directory \"\/usr\/share\/GeoIP\";\n\n        pid-file \"\/run\/named\/named.pid\";\n        session-keyfile \"\/run\/named\/session.key\";\n\n        include \"\/etc\/crypto-policies\/back-ends\/bind.config\";\n};<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The above settings allow the server to listen on port 53 for any incoming DNS requests and respond to queries from any source.<\/p>\n\n\n\n<h2 class=\"wp-block-heading is-style-text-subtitle\">Step 3: Defining the Zone Files<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create forward and reverse zone definitions within the <code>named.conf<\/code> file. These will point to the actual files that contain the DNS records.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>zone \"paessens.local\" IN {\n        type master;\n        file \"\/var\/named\/paessens.local.zone\";\n};\n\nzone \"122.168.192.in-addr.arpa\" IN {\n        type master;\n        file \"\/var\/named\/192.168.122.rev\";\n};\n<\/code><\/pre>\n\n\n\n<p class=\"is-style-default wp-block-paragraph\">Be sure to replace <code>paessens.local<\/code> with your actual domain name and adjust the reverse zone file name to reflect your network&#8217;s IP address space.<\/p>\n\n\n\n<h2 class=\"wp-block-heading is-style-text-subtitle\">Step 4: Creating Zone Files<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create the forward zone file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/var\/named\/paessens.local.zone<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Insert the DNS records for your domain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$TTL 86400\n@   IN   SOA   dns.paessens.local. admin.paessens.local. (\n               2023010401   ;Serial\n               3600         ;Refresh\n               1800         ;Retry\n               604800       ;Expire\n               86400        ;Minimum TTL\n)\n\n;Name Server Information\n@   IN   NS    dns.paessens.local.\n\n;IP address for hostname\ndns   IN   A     192.168.122.2\n\n;Additional A Records\n@        IN   A   192.168.122.1\nhost     IN   A   192.168.122.3\nengine   IN   A   192.168.122.4<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Similarly, create the reverse zone file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/var\/named\/192.168.122.rev<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And define reverse mappings:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$TTL 86400\n@   IN   SOA   dns.paessens.local. admin.paessens.local. (\n               2023010401  ;Serial\n               3600        ;Refresh\n               1800        ;Retry\n               604800      ;Expire\n               86400       ;Minimum TTL\n)\n\n@   IN   NS  dns.paessens.local.\n1   IN   PTR paessnes.local.\n2   IN   PTR dns.paessens.local.\n3   IN   PTR host.paessens.local.\n4   IN   PTR engine.paessens.local.<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading is-style-text-subtitle\">Step 5: Starting and Enabling BIND<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After configuring BIND and setting up the zone files, start the BIND service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start named<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Enable it to run on system boot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable named<\/code><\/pre>\n\n\n\n<p class=\"is-style-text-subtitle wp-block-paragraph\">References<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/reintech.io\/blog\/setting-up-primary-dns-server-bind-centos-9\">How to Set Up a Primary DNS Server with BIND on CentOS 9<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisites Step 1: Installing BIND As always start with updating the system: Once updated and reboot, install BIND and its utilties Edit the main BIND configuration file named named.conf: Inside the configuration file, set the options for your DNS server.<\/p>\n<p><a href=\"https:\/\/paessens.org\/blog\/index.php\/2024\/12\/19\/how-to-set-up-a-primary-dns-server-with-bind-on-centos-9\/\" class=\"awp-btn awp-btn-secondary awp-btn-bubble\">Continue Reading<span class=\"screen-reader-text\">How to Set Up a Primary DNS Server with BIND on CentOS 9<\/span><i class=\"fa fa-arrow-right\"><\/i><span class=\"bubble_effect\"><span class=\"circle top-left\"><\/span><span class=\"circle top-left\"><\/span><span class=\"circle top-left\"><\/span>\t<span class=\"button effect-button\"><\/span><span class=\"circle bottom-right\"><\/span>\t<span class=\"circle bottom-right\"><\/span><span class=\"circle bottom-right\"><\/span><\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[6,7],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-centos-9","tag-centos","tag-dns"],"_links":{"self":[{"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":2,"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":24,"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions\/24"}],"wp:attachment":[{"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paessens.org\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}