Solution to the problem that Centos7 cannot ping the external network in the VMware virtual machine

The Centos7 system defaults to dynamic IP. This IP allocation method requires us to reconnect based on the IP every time we connect, which is very inconvenient. There was also an article "How to set a static IP in Centos7" before. This article has more pitfall notes. Most of the time, it is necessary to combine the network configuration of Vmware to set up the Centos7 network so that it can successfully ping the external network and local windows.

Network adapter settings

On the VM page, click "Virtual Machine–>Settings–>Network Adapter–>Select NAT Mode"
Insert image description here

Virtual network settings

On the VM page, click "Edit --> Virtual Network Editor". The
Insert image description here
Insert image description here
default gateway IP here will be needed to configure a static IP later, and can be left unchanged by default.
Insert image description here
Insert image description here

Configure static IP

Edit network service files

​vim /etc/sysconfig/network-scripts/ifcfg-ens33​​

Modify the configuration:
Insert image description here
It should be noted that vim does not have enough permission to modify the read-only document here, and it will :wqshow failure. You need to use :w !sudo tee %to make the modification successful.

Edit the file again

vim /etc/resolv.conf

Add to it

nameserver 8.8.8.8
nameserver 8.8.4.4
search localdomain

Save and exit, then restart the network service.

service network restart

Then you can surf the Internet normally. Whether it is ping www.baidu.com or ping the local windows, it will show success.

If the remote connection using xshell fails, you can close the firewall and connect again.

Guess you like

Origin blog.csdn.net/h21396577548/article/details/124029011