How to configure a DNS server on CentOS 7?
To configure a DNS server on CentOS 7, you can follow these steps:
- To install the Bind software package:
Run the following command in the terminal to install the Bind software package: - Please install bind and bind-utils using sudo yum.
- Edit the main configuration file by entering the following command in the terminal: /etc/named.conf.
- Edit the named.conf file in the /etc directory using the sudo command and the vi text editor.
- Add the following content to the file:
- Options are set to listen on port 53 for any address, allow queries from any address, and enable recursion.
- Create a zone file in the /etc/named directory, such as /etc/named/example.com.zone.
- Please open the file example.com.zone located in the directory /etc/named using the text editor vi.
- Please include the following information:
- The Time to Live for this domain is 86400 seconds. The domain is administered by ns1.example.com and the admin contact is admin@example.com. The serial number is set to 2016010101. The refresh interval is 3 hours, the retry interval is 1 hour, the expiry interval is 1 week, and the minimum TTL is 1 day. The domain has an NS record pointing to ns1.example.com. The IP address for ns1 is 192.168.1.1 and the IP address for www is 192.168.1.2.
- Create a reverse zone file in the /etc/named directory, such as /etc/named/192.168.1.zone.
- Open the file “192.168.1.zone” located in the “/etc/named” directory using the text editor “vi” with superuser privileges.
- Include the following information:
- The Time To Live for this domain is set to 86400 seconds. The primary server for this domain is ns1.example.com and the administrator contact is admin.example.com. The zone serial number is 2016010101 and the refresh, retry, expiry, and minimum TTL values are set accordingly. The domain is also associated with the nameserver ns1.example.com and has pointer records for ns1.example.com and www.example.com.
- To start and configure DNS service at boot-up:
Run the following command to start the DNS service and set it to start at boot-up: - Start and enable the named service using systemctl.
- Set up firewall rules:
If the firewall is enabled, make sure to open port 53 to allow DNS traffic. - Add the DNS service to the firewall permanently using the command “sudo firewall-cmd –add-service=dns –permanent”, then reload the firewall using the command “sudo firewall-cmd –reload”.
- Test the DNS server:
Run the following command in the terminal to check if the DNS server is properly configured: - Please retrieve the information for example.com.
By following the above steps, you can successfully configure a DNS server on CentOS 7. Remember to make necessary adjustments according to your actual needs and network configuration.