1. wmware settings
This article records the mutual ping between the virtual machine and the host in the nat network mode. First use wmware to create a ubuntu virtual machine, select nat mode for network mode. Then click on Virtual Network Edit:
Next click on nat settings:
See below:
The red box above is the key, record this value, the following virtual machine will be used to set the static ip.
2. Window network settings
Open the network adapter page, select VMnet, right click -> Properties -> Internet Protocol Version 4 (TCP/IPV4) -> Properties, set the ip address to the last number of the gateway address above and change it to 1, for example, 192.168.128.2 should be set to 192.168.128.1, and set the subnet mask to 255.255.255.0 at the same time, and do not fill in the default gateway. Mine is as follows:
If you want the virtual machine to be able to access the host, you need to turn off the firewall of the host
3. ubuntu settings
Edit /etc/network/interfaces
vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
car ens33
# Change dhcp to static, then set the following address, netmask, gateway
iface ens33 inet static
address 192.168.128.129
netmask 255.255.255.0
gateway 192.168.128.2
# set dns
dns-nameservers 192.168.128.2
Then execute /etc/init.d/networking restart, or restart the virtual machine to enable the network settings.
3. Verify
Now ping 192.168.128.1 in the virtual machine can be pinged, and ping 192.168.128.129 in the host can also be pinged.