How to set up a DNS server in a Centos environment?

You can use the BIND software to set up a DNS server in a CentOS environment. Here are the steps for the setup process:

  1. Install BIND software.
  2. Please install bind and bind-utils using yum.
  3. Configure BIND:
    a. Edit the main configuration file /etc/named.conf:
  4. Please open the named.conf file using the sudo command in the vi editor.
  5. b. Specify the listening address of the DNS server in the options section.
  6. Listen for connections on port 53 for all interfaces.
  7. c. Add the following content to the zone section to specify the domain names for DNS resolution and their corresponding configuration file paths:
  8. zone “example.com” {
    type master;
    file “/etc/named/zones/example.com.db”;
    };
  9. Create a directory called /etc/named/zones, and within this directory create a file named example.com.db.
  10. Create a new directory named “zones” in the “/etc/named” directory, then open a file named “example.com.db” in the “zones” directory using the text editor “vi”.
  11. Add the following content to the example.com.db file to configure domain name resolution.
  12. The given code sets the time-to-live (TTL) to 86400 seconds and specifies the authoritative name server (NS) as ns1.example.com. Additionally, it assigns the IP address 192.168.1.10 to ns1 and 192.168.1.20 to www.
  13. Start the BIND service.
  14. Initiate the “named” service using systemctl.
  15. Set up the firewall to allow DNS traffic to pass through.
  16. Enable the DNS service for the public zone and save the setting permanently by running the first command. Then reload the firewall configuration using the second command.
  17. Enable BIND service to start automatically on boot.
  18. Enable the named service using systemctl.

Now that you have successfully set up a DNS server, you can add more domain resolution configurations by modifying the /etc/named.conf file and /etc/named/zones/example.com.db file.

bannerAds