Virtual server nat mode, nat mode virtual machine hosts ping each other

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:

1ad5acc7023c68c0c10b83c93952080f.png

Next click on nat settings:

cc3f8fe5797245222cf8b5b2bc7dfa54.png

See below:

a7cf3c7da25d1bf1358e7e2d87223475.png

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:

a60510b8b33b7a04c5b909b1662e5005.png

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324153470&siteId=291194637