Setting Up BIND
To establish a DNS server on CentOS, begin by ensuring your local package repository metadata is current:
sudo yum update -y
Install the BIND software suite and associated diagnostic utilities:
sudo yum install -y bind bind-utils
Enable the service to run on system boot and initialize it immediately:
sudo systemctl enable named
sudo systemctl start named
Modify the firewall policies to permit standard DNS traffic over both UDP and TCP:
sudo firewall-cmd --permanent --add-service=dns
sudo firewall-cmd --reload
Configuration Steps
The primary configuration file is located at /etc/named.conf. Edit this file to define your global settings, access control lists, and zone declarations:
sudo vi /etc/named.conf
Within this file, you must map zones to specific data files stored under /var/named/. A typical setup includes:
- Forward Zones: Map fully qualified domain names to IP addresses via A records.
- Reverse Zones: Map IP addresses back to domain names using PTR records.
After creating or modifying your zone files, validate the syntax to prevent service startup failures:
sudo named-checkconf
sudo named-checkzone example.com /var/named/example.com.db
Apply the changes by reloading the service:
sudo systemctl restart named
Diagnostic Techniques
When encountering resolution issues or service instability, follow these investigative steps:
-
Service Status: Check for active errors in the systemd unit file:
systemctl status named -
Log Inspection: Examine real-time events, usually found in
/var/log/messagesor specified syslog files:tail -f /var/log/messages | grep named -
Query Verification: Use the
digutility to confirm the server returns correct authoritative responses:dig @localhost example.com -
Socket Auditing: Confirm the daemon is bound to the expected network interfaces on port 53:
ss -tunlp | grep named -
Security Policy Check: If using SELinux, verify that its not blocking BIND file access or network connectivity:
ausearch -m avc -ts recent -
Permission Review: Ensure the
nameduser has read access to the/var/named/directory and all zone data files. Improper permissions are a frequent cause of 'permission denied' errors during startup. -
Resource Record Validation: Check for common syntax errors, such as missing trailing dots ('.') on FQDNs in zone files or improperly formatted PTR records for reverse lookups.