Modify/etc/resolv. conf and restore it to the original state, etcresolv. conf

Source: Internet
Author: User

Modify/etc/resolv. conf and restore it to the original state, etcresolv. conf

Ping: unknown host www.baidu.com ???

Modify/etc/resolv. conf. After the network adapter is restarted,/etc/resolv. conf is restored to the original state.

You cannot directly modify/etc/resolv. conf under CentOS or redhat. You must add the dns settings in/etc/sysconfig/network-scripts/ifcfg-eth0. Otherwise, after the restart, you must use the eth0 settings without dns information to restore/etc/resolv. conf to the original state.

Modify/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE = eth0
BOOTPROTO = none
HWADDR = 00: xx: 19: xx
ONBOOT = yes
TYPE = Ethernet
USERCTL = no
IPV6INIT = no
PEERDNS = yes
NETMASK = 255.255.255.0
IPADDR = xxx. xxx
GATEWAY = xxx. xxx
DNS1 = 202.0.0.6

After this setting, you do not need to set it in/etc/resolv. conf. After service network restart, we can find that there are two dns resolution ip addresses in/etc/resolv. conf. Restart the network after configuration. For cat/etc/resolv. conf, you can see the following parameters:

# Generated by NetworkManager
Nameserver 202.0.0.6
Search localdomain

DNS resolution settings are successful.
Note ::::It is useless to directly modify the/etc/resolv. conf file. After the network service is restarted, the configuration will be reloaded according to/etc/sysconfig/network-scripts/ifcfg-eth0.

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.