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:
- Install BIND software.
- Please install bind and bind-utils using yum.
- Configure BIND:
a. Edit the main configuration file /etc/named.conf: - Please open the named.conf file using the sudo command in the vi editor.
- b. Specify the listening address of the DNS server in the options section.
- Listen for connections on port 53 for all interfaces.
- c. Add the following content to the zone section to specify the domain names for DNS resolution and their corresponding configuration file paths:
- zone “example.com” {
type master;
file “/etc/named/zones/example.com.db”;
}; - Create a directory called /etc/named/zones, and within this directory create a file named example.com.db.
- 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”.
- Add the following content to the example.com.db file to configure domain name resolution.
- 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.
- Start the BIND service.
- Initiate the “named” service using systemctl.
- Set up the firewall to allow DNS traffic to pass through.
- 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.
- Enable BIND service to start automatically on boot.
- 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.