Phenomenon: The host machine and the virtual machine can ping each other, and the host machine can ping the external network, but the virtual machine cannot ping the external network
Reason: The gateway setting of vmware is wrong
1) View linux network configuration information
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=4af77be9-c7c7-4245-acac-afc2b7f91e49
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
HWADDR=00:50:56:26:15:DE
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
IPADDR=192.168.137.3
NETMASK=255.255.255.0
GATEWAY=192.168.137.254 #linux网关与vmware网关需一致才行
DNS1=114.114.114.114
DNS2=10.111.1.2
2) Click: Virtual Network Editor
3) Click: Change Settings → VMnet8 → NAT Settings
4) Keep the vmware gateway consistent with the linux gateway
5) Restart the network card
[root@localhost ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Determining if ip address 192.168.137.3 is already in use for device eth0... [ OK ]
6) Ping Baidu
[root@localhost ~]# ping baidu.com
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66: icmp_seq=1 ttl=128 time=60.3 ms
64 bytes from 110.242.68.66: icmp_seq=2 ttl=128 time=64.3 ms