Introduced
When we configure CentOS, many cases need to be able to extranet, then need DNS parsing function, the default is not configured DNS information, so we have to configure DNS information
Cause
We are in search of CentOS configuration DNS information, a lot of is said in this file to configure "/etc/resolv.conf", we have added a nameserver after this can really ping the domain name, However, after restarting the CentOS or restarting the network service, you cannot ping it, and the nameserver information in the "/etc/resolv.conf" configuration is also lost.
Processing
We found the corresponding NIC configuration file "/etc/sysconfig/network-scripts/ifcfg-eth<n>"
Here <N> can be 0, 1, 2, and so on, representing the different network card configuration files.
For example, the first card on the system is eth0, and its configuration file is/etc/sysconfig/network-scripts/ifcfg-eth0.
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
After opening, insert the following 3 bars
Peerdns=no
dns1=192.168.1.1
dns2=192.168.1.2
Then: Wq Save
And then we'll review the "/etc/resolv.conf."
Cat/etc/resolv.conf
found that the DNS information we modified in Ifcfg-eth0 can be seen in resolv.conf, which is why columns, because resolve.conf is just a link file.
And then we look at the effect.
Ping www.baidu.com
And then we restart the Network service.
Service Network restart
And then we'll ping the
Found that there was no problem
And then we'll reboot the system.
Reboot
The result is exactly what we expected.
Github:https://github.com/sinodzh/linux/blob/master/dns.txt
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.