Setting DNS Server in CentOS
Setting up a Domain Name System (DNS) server is essential for any CentOS system to properly resolve domain names to IP addresses. In this article, we will guide you on how to set a DNS server in CentOS.
There are various ways to configure DNS servers in CentOS, but we will focus on the most common method using the resolve.conf
file.
Before we begin, make sure you have root access to your CentOS system, as we will be making changes to system settings.
Step 1: Edit resolv.conf File
The resolve.conf
file is where CentOS stores DNS settings. To edit this file, open a terminal and type the following command:
sudo nano /etc/resolv.conf
Once the file is opened, you will see lines similar to the following:
# Generated by NetworkManager
nameserver 127.0.0.1
To set a custom DNS server, simply add a new line with the following format:
nameserver [DNS_SERVER_IP]
Replace [DNS_SERVER_IP]
with the IP address of the DNS server you want to use. Save the file and exit the editor.
Step 2: Restart Network Service
After editing the resolve.conf
file, you will need to restart the network service for the changes to take effect. To do this, type the following command in the terminal:
sudo systemctl restart NetworkManager
Once the network service is restarted, your CentOS system should now be using the custom DNS server you configured.
Conclusion
In this article, we have shown you how to set a DNS server in CentOS using the resolve.conf
file. By following these simple steps, you can ensure that your CentOS system resolves domain names correctly and efficiently.
Remember to always double-check your DNS server settings to avoid any connectivity issues on your CentOS system.