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...