[VMware] There are three network connection modes for VM virtual machines, bridge, NAT, and host only. Network card vmnet0, vmnet1, vmnet8 difference

There are three network connection modes for VM virtual machines, bridge, NAT, and host only. Network card vmnet0, vmnet1, vmnet8 difference

introduction:

In VMware, the network connection of the virtual machine is mainly implemented by a virtual switch (also called a virtual network) created by VMware, and VMware can create multiple virtual networks as required.

VMware's virtual network is named in the form of "VMnet+number", such as VMnet0, VMnet1,
VMnet2
...and so on (on the host of the Linux system, the name of the virtual network is in lowercase, such as vmnet0).

A switch is a device connected to the same local area network, which performs simple storage and forwarding without any changes to the data.

Therefore , the network connection of the virtual machine (communication with the local host, etc., communication between the virtual machine and the virtual machine) is realized by the virtual switch.

Summary of the differences between the three network cards

①Adapter=VMnet1=eth0(host-only) host only

Mutual access between virtual machines and
mutual access between hosts and virtual machines
But virtual machines cannot access the external network.
The virtual machine cannot be accessed from the external network.

②Adapter2=VMnet8=eth8(nat) NAT network address translation

Mutual visits between virtual machines
Mutual visits between hosts and virtual machines.
The virtual machine can access the external network through the host*.
The external network cannot access the virtual machine.

Using the NAT network mode, install multiple virtual machines on the host, and form a small local area network with the host. The host and virtual machines can communicate with each other, and the virtual machines can also access the external network, such as building hadoop clusters and distributed services.

③Adapter3=VMnet0=eth2(Bridged) bridge mode

Mutual visits between virtual machines
Mutual visits between hosts and virtual machines.
The virtual machine** can access the external network through the host,
and the external network can access the virtual machine.

A virtual machine is equivalent to a physical machine, which can be freely accessed and accessed and surf the Internet .

My computer access example

When installing VMware workstation, 3 virtual network cards will be installed by default, namely VMnet0, VMnet1, and VMnet8.
Virtual machine virtual network card -----------connection-------corresponding virtual network --------------connection------- ----The local host network card
can communicate in this way.

1. The ip of my local computer on the VMnet8 virtual network is 192.168.111.1
!](https://img-blog.csdnimg.cn/ff0d41d58e4945289a1e862334201574.png)
insert image description here
2. My ubuntu virtual machine (the selected mode is nat mode, corresponding to the network ip in the VMnet8 network) is 192.168.111.128
insert image description here
3. You can take a look at the virtual network editor
insert image description here

virtual network card name network properties definition
VMnet0 physical network card Bridge bridge
Vmnet1 virtual network card host-only host only
VMnet8 virtual network card NAT

The following is the ip-analysis that appears in various places on the computer

1. Bridge mode

Because the wireless network card cannot be bridged.
In fact, there is no information, and there is no corresponding vmnet0 network card under window, and there is no ip under ubuntu, and the Internet cannot be accessed.

As a reminder: the wireless network card virtual machine can be bridged, Vmware0 is the virtual network that the virtual machine enters by default, open the virtual network editor to bridge Vmware0 to the specific wireless network card, and then open the network card settings to select the bridge mode.

2. In NAT mode

VMnet8 under windows: IPv4 address. . . . . . . . . : 192.168.195.1

ubuntu下:inet… 192.168.195.128

vm virtual network editor, nat mode - subnet address... 192.168.195.0

The same subnet** can communicate with each other**. You can surf the Internet.

3. Only in host mode

VMnet1 under window: IPv4 address. . . . . . . . . : 192.168.232.1

ubuntu下:inet… 192.168.232.128

vm virtual network editor, only host mode - subnet address... 192.168.232.0
is the same subnet, and can communicate with each other . But can't go online .

Three Network Connection Modes

*1. Bridge mode (B): directly connected to the physical network*

The virtual network adapter of the virtual machine is handed over to the physical network adapter of the host, and the virtual network adapter in the virtual machine can directly access the external network through the physical network adapter in the host. In short, it's like adding a new, separate computer to your LAN. Therefore, the virtual machine also occupies an IP address in the local area network , and can communicate with other terminals.

*2. NAT mode (N): used to share the IP address of the host*

NAT is the abbreviation of Network Address Translation, which means network address translation. NAT mode is also the default network connection mode for VMware to create virtual machines. When using a NAT mode network connection, **VMware will establish a separate private network on the host to communicate between the host and the virtual machine. **The request data "package" sent by the virtual machine to the external network will be handed over to the NAT network adapter with a "special mark"** and forwarded in the name of the host. The response data "package" returned by the external network is also first sent by The host receives it, and then the NAT network adapter identifies it according to the "special mark" and forwards it to the corresponding virtual machine. **Therefore, the virtual machine does not need to have its own IP address in the external network. From the perspective of the external network, the virtual machine and the host are sharing an IP address. By default, external network terminals cannot access the virtual machine.

Additionally, only one NAT-mode virtual network is allowed on a host . Therefore, multiple virtual machines connected to the NAT mode network on the same host can also access each other .

As we mentioned earlier, by default, the external network cannot access the virtual machine, but we can also manually modify the NAT settings to implement port forwarding, and forward the data sent from the external network to the specified port of the host to the specified virtual machine. For example, we "established" a site on port 80 of the virtual machine. As long as we set port forwarding and forward the data on port 88 of the host to port 80 of the virtual machine, the external network can be accessed through port 88 of the host. The site on port 80 of the virtual machine.

*3. Host-only mode (U): private network shared with the host*

The host-only mode is a more closed network connection mode than the NAT mode, which will create a private network completely contained in the host. A host-only virtual network adapter is visible only to the host and provides network connectivity between the virtual machine and the host system. Compared with the NAT mode, the host-only mode does not have the NAT function, so by default, the virtual machine using the host-only mode network connection cannot connect to the Internet (install appropriate routing or proxy software on the host, or If you use the Internet Connection Sharing function on the host machine, you can still connect the virtual machine to the Internet or other networks).

Multiple host-only virtual networks can be created on the same host. If multiple virtual machines are in the same host-only network, they can communicate with each other; if they are in different host-only networks, By default, they cannot communicate with each other (you can communicate with each other by setting up a router between them).

Guess you like

Origin blog.csdn.net/m0_57168310/article/details/127966993