How to Set Up Bind DNS on CentOS 8: A Step‑by‑Step Guide
This tutorial walks through installing and configuring the Bind DNS service on a CentOS 8.3 virtual machine, covering environment preparation, SELinux and firewall settings, main and zone file configuration, and how to start and verify the DNS server.
DNS Forward Lookup
Experiment environment:
CentOS 8.3.2011 IP address 192.168.100.50, VMware NAT network, domain to resolve test.com.
Environment preparation
Configure yum repository (omitted) and install common tools. # yum install -y vim net-tools bind bind-utils Disable SELinux and firewall (or open DNS ports).
# setenforce 0 # temporary disable SELinux (will revert after reboot)# systemctl stop firewalld && systemctl disable firewalldPermanent SELinux disable by editing the configuration file. # vim /etc/sysconfig/selinux Change SELINUX=enforcing to SELINUX=disabled and save.
Open firewall for DNS service.
# firewall-cmd --add-service=dns --permanent# firewall-cmd --reloadExperiment steps
Edit the main Bind configuration file /etc/named.conf. The file is divided into global options, logging, zone definitions, and include statements. # vim /etc/named.conf Adjust the global options so the server listens on all addresses and allows any host.
Define a zone for test.com directly in the main file (remember the trailing semicolons).
Zone types supported by Bind:
Forward (转发)
Master (主)
Slave (从)
Hint (根)
Zone files are stored under /var/named. Copy the example file and edit it.
# cp named.localhost test.com.zones
# vim test.com.zonesThe @ symbol represents the current origin (the zone name). $TTL sets the default TTL, and the SOA record is mandatory as the first record in the file.
4.3.5.1. The @ (at‑sign) When used in the label (or name) field, the at‑sign represents the current origin. At the start of the zone file, it is the <zone_name> followed by a trailing dot (.).
Typical records in the zone file:
NS records specify which name servers serve the zone.
A records map a domain name to an IPv4 address.
AAAA records map a domain name to an IPv6 address.
After editing, set proper ownership and enable the service.
# chgrp named test.com.zones# systemctl enable --now namedTest the DNS resolution from the host.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
