Solution to the failure to identify host causes when using CentOS to ping Baidu

Source: Internet
Author: User

Solution to the failure to identify host causes when using CentOS to ping Baidu

This problem has occurred many times before.

The premise is that the host can be pinged.

The scenario is that when you use yum to upgrade the libxml2 library, you will encounter a host that cannot parse centos. Generally, the DNS of the gateway and centos is not set.

Solution:

1. Set the VM Nic as shown in the figure below:

In this way, the network adapter from the VM to the local host will be switched over to Baidu.

2. View windows network settings

Ifconfig/all

Set the parameters in centos.

3. Check whether the centos gateway is set correctly.

[Root @ localhost ethan] # grep GATEWAY/etc/sysconfig/network-scripts/ifcfg *
/Etc/sysconfig/network-scripts/ifcfg-eth0: GATEWAY = 192.168.199.1

If it is incorrect, set it as follows:

[Root @ localhost ethan] # vim/etc/resolv. conf is as follows:

Nameserver 192.168.199.1
Search localdomain

Check whether DNS resolution files are used.

[Root @ localhost ethan] # grep hosts/etc/nsswitch. conf is as follows:
# Hosts: db files nisplus nis dns
Hosts: files dns

Set Gateway:

[Root @ localhost ethan] # vim/etc/sysconfig/network is as follows:

NETWORKING = yes
HOSTNAME = localhost. localdomain
GATEWAY = 192.168.199.1

[Root @ localhost ethan] # vim/etc/sysconfig/network-scripts/ifcfg-eth0 is as follows:

TYPE = Ethernet
BOOTPROTO = static
DEVICE = eth0
IPADDR = 192.168.199.213
NETMASK = 255.255.255.0
ONBOOT = yes
GATEWAY = 192.168.199.1

4. Restart the network service.

Service network restart

In general, you can ping it after it is done ....

Baidu is not enough...

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.