[Source] After Centos modifies DNS to restart or restarts the network service, the problem is lost. centosdns
This article is copyrighted by mephisto and the blog Park. You are welcome to repost it, but you must keep this statement and provide the original article link. Thank you for your cooperation.
Written by mephisto, SourceLink
Reading directory
- Introduction
- Cause
- Processing
- GitHub
This article is copyrighted by mephisto and the blog Park. You are welcome to repost it, but you must keep this statement and provide the original article link. Thank you for your cooperation.
Written by mephisto, SourceLink
Introduction
When we configure Centos, we need to be able to connect to the Internet in many cases, so we need the DNS resolution function. By default, DNS information is not configured, so we need to configure DNS information.
Cause
When we search for the Centos DNS configuration information, many of them refer to configuring in this file "/etc/resolv. conf ", we can ping the domain name after adding the nameserver in it, but it cannot be pinged after restarting centos or the network service. In"/etc/resolv. conf "the configured nameserver information is also lost.
Processing
Find the corresponding Nic configuration file "/etc/sysconfig/network-scripts/ifcfg-eth <N>"
Here, <N> can be 0, 1, 2, and so on, representing the configuration files of different NICs.
For example, if the first network adapter in the system is eth0, its configuration file is/etc/sysconfig/network-scripts/ifcfg-eth0.
vim /etc/sysconfig/network-scripts/ifcfg-eth0
Insert the following three
PEERDNS=noDNS1=192.168.1.1DNS2=192.168.1.2
Then: wq save
Then let's review "/etc/resolv. conf"
cat /etc/resolv.conf
We found that the DNS information we modified in the ifcfg-eth0 can be seen in resolv. conf, which is why the column, because resolve. conf is just a link file.
Then let's take a look at the effect.
ping www.baidu.com
Then we restart the network service.
service network restart
Then ping
No problem found
Then, restart the system.
reboot
The result is what we expected.
GitHub
https://github.com/sinodzh/Linux/blob/master/dns.txt
This article is copyrighted by mephisto and the blog Park. You are welcome to repost it, but you must keep this statement and provide the original article link. Thank you for your cooperation.
Written by mephisto, SourceLink