How to set up a DNS resolver server on CentOS 7?

To set up a DNS resolver server on CentOS 7, you can follow the steps below:

  1. Install the bind software package.
  2. Please use the command “sudo yum install bind bind-utils” to install the necessary packages.
  3. Edit the main configuration file:
    Open the main configuration file /etc/named.conf and make the following modifications to it:
  4. Add the following lines below the options section to configure the IP address and domain name of the DNS server:
    listen-on port 53 { any; };
    listen-on-v6 port 53 { ::1; };
    allow-query { any; };
    allow-transfer { none; };
    allow-recursion { localhost; };
    recursion yes;
  5. Comment out the path to the /etc/named.iscdlv.key file, as it does not exist in CentOS 7.
  6. Create a zone file:
    Create the following zone file in the /etc/named directory:
  7. Create a main zone file named example.com.zone and add the following content to the file (replace example.com with your own domain name): $TTL 86400
    @ IN SOA ns1.example.com. admin.example.com. (
    2019100101 ; Serial
    3600 ; Refresh
    1800 ; Retry
    604800 ; Expire
    86400 ; Minimum TTL
    )
    @ IN NS ns1.example.com.
    @ IN A DNS server IP address
    www IN A server IP address
  8. Configure reverse resolution area files: Create the following reverse resolution area files in the /etc/named directory (replace the x in the IP addresses with the actual IP address):
  9. Create a reverse lookup file named x.x.x.in-addr.arpa.zone and add the following content to the file (replace the ‘x’ in the IP address with the actual IP address):
    $TTL 86400
    @ IN SOA ns1.example.com. admin.example.com. (
    2019100101 ; Serial
    3600 ; Refresh
    1800 ; Retry
    604800 ; Expire
    86400 ; Minimum TTL
    )
    @ IN NS ns1.example.com.
    x IN PTR example.com.
  10. Set up a firewall:
    If your CentOS 7 server has a firewall such as iptables, make sure to allow DNS traffic to pass through. You can enable DNS traffic using the following command:
  11. Add the DNS service to the firewall permanently and then reload the firewall.
  12. Start and enable the bind service.
  13. Start and enable the named service using systemctl.

After completing the above steps, your CentOS 7 server should have set up a DNS resolving server. To test if it is functioning correctly, you can use the nslookup command or other DNS resolving tools to query domain name resolution.

bannerAds