CentOS Modify the DNS reboot or restart the network service for loss of troubleshooting _linux

Source: Internet
Author: User
Tags nameserver

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.