Software used: VMware Workstation, Windows10, Centos7
Reason (everyone’s problems are not necessarily the same, here is a description of the situation I encountered): My virtual machine’s network connection mode is "NAT mode", and my laptop is in a different LAN , the ip automatically assigned to the host machine and the virtual machine will change, but the configuration of the "virtual network editor" of the virtual machine has not changed. The host machine and the virtual machine are in different network segments, resulting in a failure to ping each other.
(Note: Commands to view ip in different environments, windows: ipconfig
or ipconfig/all
, linux: ifconfig
)
Solution:
-
The network connection mode of the virtual machine is , and vmware will generate a virtual network card VMware Network Adapter VMnet8
NAT模式
on the host accordingly , and find this virtual network card through the following path: Control Panel => Network and Internet => Network and Sharing Center => Change Adapter Settings
-
Run VMware as an administrator (because modifying network settings requires administrator privileges), find the "Virtual Network Editor" page through the following path: Edit => Virtual Network Editor , generally switch LAN, you need to click "Restore Default Settings" To reassign the gateway and subnet ip to the virtual machine
-
Open the virtual network editor => VMnet8 => NAT settings , view the gateway assigned by the virtual machine, configure the ipv4 protocol in the virtual network card VMware Network Adapter VMnet8 according to this gateway , and then confirm to save. It is best to restart the virtual network card to be safe. You can try whether the host machine and the virtual machine can communicate with each other (Note: the custom ip address and gateway must be on the same network segment as the virtual machine)
If you encounter a virtual machine that cannot connect to the network, you can click this link