VMWare virtual machine and the local host cannot ping each other

[Problem Solving Notes] VMWare virtual machine and the local host cannot ping each other

 

Link to this article: https://blog.csdn.net/LanTingShuXu/article/details/80795542

When using VMWare to install the virtual machine, I will encounter the local and the virtual machine cannot ping each other. Every time the problem is solved, it is solved by searching and solving the tutorial. In order to break this nightmare, I specially write it down, I am afraid that I will forget it next time~ ~~

Note: The network mode used by my virtual machine is: NAT mode

1. Set the subnet and mask information for NAT and
click "Edit" in the VMWare menu bar —> Virtual Network Editor [the first picture below] —> select VMnet8 (Of course, this depends on the suffix of your device, as long as The external connection mode is NAT mode. If not, just click Add Network and add a NAT.) Set a subnet IP and subnet mask without conflict. I set 192.168.77.0 and 255.255.255.0. Other reference diagrams [the second picture below] —> Click "NAT Settings", and fill in a gateway in the gateway IP (do not conflict with the existing ones, for example, I filled in 192.168.77.1) [the figure below Three pictures] —> After setting NAT, click "DHCP Settings", which is mainly used to allocate the IP allocation interval. I set here from 192.168.77.128 to 192.168.77.254 [the fourth picture below]
The screenshot of the specific process Screenshot below.
Write picture description here
Write picture description here
Write picture description here
Write picture description here

2. Configure the NAT mode
for the virtual machine. The network mode of the virtual machine I installed is NAT mode. The
specific setting method is: right-click the created virtual machine—>Settings—>Network Adapter—>NAT Mode
Example

3. Assign an IP to the virtual machine.
If the virtual machine is installed and the automatic acquisition of IP is checked in the network configuration, restart it.
The method of using static IP is mainly recorded here:
Method 1: Use setup commands to make visual modifications in the command terminal of the virtual machine  .
Method 2: Use the command: vi /etc/sysconfig/network-scripts/ifcfg-ens33modify the content as follows (if not, add it):

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes #是否开机启用
BOOTPROTO=static #ip地址设置为静态
IPADDR=192.168.77.128 #虚拟机的IP(必须和第一步设置的网关IP在一个网段)
NETMASK=255.255.255.0  #子网掩码

# 如果上面的静态IP配置方式会导致虚拟机无法连接外网,可以使用一下配置(使用自动分配IP)
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes #是否开机启用
BOOTPROTO=dhcp #ip地址设置为dhcp分配
NETMASK=255.255.255.0  #子网掩码

 

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
IPADDR="192.168.23.100"
NETMASK="255.255.255.0"
GATEWAY="192.168.23.2"
DNS1="192.168.23.2"
DNS2="8.8.8.8"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="b3989d88-5efe-4d52-ab11-6d6cd635e529"
DEVICE="ens33"
ONBOOT="yes"
~     

 

Restart after setting to take effect 

service network restart

 

4. Configure a static IP for the virtual network card of the computer.
Find the network and sharing center of our computer, find the network connection, the VMware Network Adapter VMnet8 that we configured in the first step, right click and select properties
Write picture description here

Configure a static IP in IPV4, and the IP network segment here should be the same as the one configured in the first step
Write picture description here

At this point, all configurations are complete!

A brief summary: There are mainly three core configuration points here:
1) Configure the NAT mode first, which is mainly to configure the subnet IP, mask, gateway and other information. We can understand this as configuring a virtual gateway.
2) Under the premise of satisfying the first step, configure the IP for the virtual machine, and this IP must be in the same network segment as the information set in the first step.
3) Configure the IP for your own computer, which must also be in the same network segment as the one configured in the first step. A network segment.

In this way, after the virtual machine, gateway, and computer network segments are unified, the network is connected. The schematic diagram is as follows:
Write picture description here

Category:  linux

Guess you like

Origin blog.csdn.net/qq_42533216/article/details/114259197