CentOS 7 DNS Configuration Guide

To change the DNS configuration file in CentOS 7, follow these steps:

  1. the resolv.conf file
sudo vi /etc/resolv.conf
  1. In the open file, you can see content similar to the following:
# Generated by NetworkManager
nameserver 192.168.1.1
  1. Domain name server
nameserver 8.8.8.8
nameserver 8.8.4.4
  1. Save the file and exit the text editor.
  2. Restart the network service to apply the new DNS configuration.
sudo systemctl restart network

Once you have completed the above steps, you have successfully modified the DNS configuration file in CentOS 7. Note that if you are using NetworkManager for network configuration management, it may override the /etc/resolv.conf file. In such cases, you can specify the DNS server in the NetworkManager configuration file or set /etc/resolv.conf to read-only to prevent it from being overwritten.

bannerAds