How to Setup DNS Server using Bind 9 on CentOS 7

Start by installing BIND 9, the DNS server software, using the following command: sudo yum install bind bind-utils

Install BIND 9 DNS Server

Open the BIND configuration file to set options like allowed query IPs: sudo nano /etc/named.conf Add your network and set listen-on and allow-query to your network IP range.

Configure BIND Options

Define your DNS zones by creating zone entries in /etc/named.conf. Add both forward and reverse zones for your domain:

Create Zone Files

Create the forward zone file to map domain names to IP addresses: sudo nano /var/named/example.com.db

Configure Forward Zone File

Create the reverse zone file to map IP addresses to domain names: sudo nano /var/named/1.168.192.db Enter PTR records to link IP addresses back to domain names.

Configure Reverse Zone File

Ensure the zone files have correct ownership and permissions so that BIND can access them: sudo chown named:named /var/named/example.com.db

Set Correct File Permissions

Start the DNS service and enable it on boot. Then test your DNS server: sudo systemctl start named sudo systemctl enable named nslookup example.com

Start and Test BIND DNS Service