How to Set Up and Configure Bind DNS on CentOS 8 – Step‑by‑Step Guide
This tutorial walks through installing Bind on CentOS 8, disabling SELinux and the firewall, configuring /etc/named.conf and zone files for the test.com domain, setting proper permissions, enabling the named service, and verifying DNS resolution.
Environment and Prerequisites
The lab runs on CentOS 8.3 (IP 192.168.100.50) inside a VMware NAT network. The target domain to resolve is test.com.
Install Required Packages
# yum install -y vim net-tools bind bind-utilsDisable SELinux and Firewall
Temporarily turn off SELinux: # setenforce 0 To disable SELinux permanently, edit /etc/sysconfig/selinux and change SELINUX=enforcing to SELINUX=disabled.
Stop and disable firewalld, then open the DNS service port:
# systemctl stop firewalld && systemctl disable firewalld
# firewall-cmd --add-service=dns --permanent
# firewall-cmd --reloadConfigure Bind
The main configuration file is /etc/named.conf; zone files reside under /var/named. The service runs as the named user.
Edit the main file: # vim /etc/named.conf Typical sections include options (global settings), logging , zone definitions, and include statements. Ensure the server listens on all interfaces and permits any host to query.
Define a master zone for test.com directly in named.conf (remember the trailing semicolon):
zone "test.com" IN {
type master;
file "test.com.zones";
allow-update { none; };
};Create the Zone File
Navigate to /var/named, copy the template, and edit it:
# cd /var/named
# cp named.localhost test.com.zones
# vim test.com.zonesKey directives in the zone file: $TTL – default time‑to‑live (usually 1 day). @ IN SOA ns.test.com. rname.invalid. ( … ) – mandatory start‑of‑authority record. NS – specifies authoritative name servers. A – maps a hostname to an IPv4 address. AAAA – maps a hostname to an IPv6 address.
The $ORIGIN variable automatically appends the zone name (e.g., test.com.) to records that are not fully qualified.
Set Permissions and Start the Service
# chgrp named test.com.zones
# systemctl enable --now namedVerify DNS Resolution
Use a client on the host to query the new zone. Successful resolution confirms the configuration.
Reference: https://www.cnblogs.com/RichardLuo/p/DNS_P1.html
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
