There are many different ways to configure DNS services in CentOS 7 systems. This article will introduce the two most common methods: using NetworkManager and using the resolv.conf file.
NetworkManager is a common network manager that can help users manage system network configuration. The following are the steps to configure DNS service using NetworkManager:
Open the NetworkManager configuration file:
$ sudo vi /etc/NetworkManager/NetworkManager.conf
Add the following content to the file:
[main]dns=none[ipv4]dns-search=example.commethod=auto[ipv6]dns-search=example.commethod=auto
The above configuration means using NetworkManager to manage network settings, but disabling DNS settings. In addition, the default DNS search domain is configured as example.com.
Restart the NetworkManager service:
$ sudo systemctl restart NetworkManager
Confirm that the DNS service has been configured successfully:
$ nmcli dev show | grep DNS
The output should contain the configured DNS search domains and DNS servers.
The resolv.conf file is the most common method used to configure DNS services. Here are the steps to configure the DNS service using the resolv.conf file:
Open the resolv.conf file:
$ sudo vi /etc/resolv.conf
Add the following content to the file:
nameserver 8.8.8.8nameserver 8.8.4.4
The above configuration uses Google public DNS server as the default DNS server.
Confirm that the DNS service has been configured successfully:
$ nslookup example.com
If the domain name can be successfully resolved, the DNS service has been configured successfully.
In short, the above two methods are commonly used methods to configure DNS services on CentOS 7 systems. Users can choose one of the methods for configuration according to their own needs.
The above is the detailed content of Centos7 system configuration DNS service. For more information, please follow other related articles on the PHP Chinese website!