[ubuntu] The bridge mode and NAT mode of the virtual machine are different from the host only (easy to understand)

 

Table of contents

1. Bridge mode

Statement one

Statement two

Statement three

2. NAT mode

Statement one

Statement two

3. Host-only mode


 

1. Bridge mode

Statement one

Bridge mode: directly connected to the physical network, that is, the network connected to your switch and the IP of your host are on the same network segment.

The computer from the virtual machine is directly connected to the current network environment and has an exclusive IP.

Features: All computers in the current network can access the virtual machine.

Disadvantages:

1.Ip address may change 192.150.1.100/192.168.1.101

2. If you need to rely on switches/routers when transferring files at this time

Statement two

In a virtual machine (Virtual Machine), bridge mode (Bridge Mode) is a network configuration mode used to connect a virtual machine to a physical network.

In bridged mode, the virtual machine's network adapter (Network Adapter) is connected to the physical network adapter through a virtual bridge (Virtual Bridge). This allows virtual machines to communicate directly with other devices on the physical network as if they were connected on the same physical network.

The main advantages of bridge mode are:

  1. Transparency: The communication between the virtual machine and the physical network is transparent, and the virtual machine does not require additional configuration or network address translation.

  2. Direct Access: A virtual machine can directly access other devices on the LAN, including other virtual machines and physical devices.

  3. Network management: Virtual machines use the same network configuration and management tools as physical networks.

To configure bridged mode for a virtual machine, you typically need to perform the following steps:

  1. Create a virtual machine in the virtualization software and select bridged mode as the configuration option for the network adapter.

  2. Specify the relevant parameters of the bridge mode, such as selecting the physical network adapter to be bridged, setting the IP address, and so on.

  3. After starting the virtual machine, the virtual machine's network adapter will automatically connect to the specified physical network adapter.

It should be noted that configuring bridge mode may require administrator privileges and may involve network setup and security considerations. Therefore, when configuring the network of a virtual machine, be sure to understand the relevant network knowledge and security practices, and ensure that the configuration is in compliance with the organization's policies and needs.

To sum up, the bridging mode of a virtual machine is a network configuration mode that connects a virtual machine to a physical network, which allows the virtual machine to directly access other devices in the physical network and use the same network management tools as the physical network.

Statement three

In the bridging mode, the virtual machine is like an independent host and has the same status as the physical host. It can access the external network through the network card of the physical host, and computers in the external network can also access this virtual machine. Set an IP address on the same network segment as the physical network card for the virtual machine, and the virtual machine can freely communicate with the physical host and all hosts in the LAN. Bridge mode is shown in the figure.

 The virtual network name corresponding to bridge mode is VMnet0. In bridge mode, the virtual machine actually communicates through the network card of the physical host. If the physical host has multiple NICs (such as a wired NIC and a wireless NIC), then it is also necessary to pay attention to which physical NIC the virtual machine is actually bridged to.
    Open the "Virtual Network Editor" in the "Edit menu", and you can set the physical network card to which the VMnet0 network is bridged, as shown in the figure

2. NAT mode

Statement one

In the virtual machine (Virtual Machine), NAT mode (Network Address Translation Mode) is a network configuration mode, which is used to connect the virtual machine to the physical network and realize the communication with the external network.

In NAT mode, the network adapter (Network Adapter) of the virtual machine creates a private network through virtual network devices and virtualization software. The virtual machine is assigned an IP address in the private network and uses that address for internal communication.

When the virtual machine needs to communicate with the external network, the virtualization software will forward the network traffic of the virtual machine to the host machine (Host Machine). The host uses Network Address Translation (NAT) technology to translate the private IP address of the virtual machine into a routable public IP address of the host on the external network, and maintains a forwarding table to track the network connection of the virtual machine.

The main advantages of NAT mode are:

  1. Ease of use: The setting of NAT mode is relatively simple and does not require additional network configuration or administrator privileges.

  2. Security: The private IP address of the virtual machine is hidden from the external network, and only the public IP address of the host machine is visible to the outside world, providing a certain degree of security protection.

  3. Shared host network: Multiple virtual machines can share the network connection of the host and use the same public IP address for external network communication.

To configure the NAT mode of a virtual machine, you generally need to perform the following steps:

  1. Create a virtual machine in the virtualization software, and select NAT mode as the configuration option of the network adapter.

  2. After starting the virtual machine, the virtual machine will be assigned a private IP address and automatically connected to the private network created by the virtualization software.

  3. The virtual machine can use the private IP address for internal communication, while the external network communication will be forwarded through the public IP address of the host machine.

It should be noted that the virtual machine cannot be directly accessed from the external network in NAT mode, but a certain degree of external access can be achieved through technologies such as port forwarding. In addition, since the NAT mode performs address translation through the host machine, the network performance and configuration of the host machine may have an impact on the network performance of the virtual machine.

In summary, the NAT mode of a virtual machine is a network configuration mode that connects a virtual machine to a physical network and communicates with an external network. It converts the private IP address of the virtual machine into a public IP address through the Network Address Translation technology of the host machine, providing an easy-to-use and secure network connection method.

Statement two

The virtual network corresponding to the NAT mode is "VMnet8", which is also an independent network . In this mode, the physical host is like a proxy server supporting the NAT function , and the virtual machine is like a NAT client. The virtual machine can use the IP address of the physical host to directly access computers in the external network , but it is controlled by thousands of servers. The characteristics of NAT technology ( Network Address Translation), the computer in the external network cannot actively communicate with the virtual machine in NAT mode, that is to say, there can only be one-way communication from the virtual machine to the external network computer.

Of course, the physical host and the virtual machine in NAT mode can communicate with each other, provided that the IP address of the virtual machine is in the same network segment as the IP address of the VMnet8 network card. Similarly, in order to facilitate unified management, it is recommended to  set the IP address segment used by the "VMnet8" network to 192.168.80.0/24.

If the physical host has been connected to the Internet, you only need to set the network of the virtual machine to NAT mode, and the virtual machine can automatically connect to the Internet. Therefore, if the virtual machine needs to access the Internet, it is very suitable to set it to NAT mode.

3. Host-only mode

The host-only mode corresponds to the virtual network , "VMnet1". VMnet1 is an independent virtual network , which is isolated from the physical network (see figure). That is, all virtual machines set to host-only mode can communicate with each other and between virtual machines and physical hosts, but they cannot communicate with hosts on the external network .

Guess you like

Origin blog.csdn.net/fanjufei123456/article/details/132226883