The Secret of VMware Network Mode: Create an Efficient and Stable Virtual Machine Communication Network

A VMWare network connection

1.1 View VM network mode

insert image description here
insert image description here
insert image description here

1.2 Three network modes of VMWare

  • In the VMware virtualization environment, there are three main network modes, they are: bridged mode (Bridged Mode), NAT mode (Network Address Translation Mode) and host mode (Host-Only Mode) . These network modes are used to configure how virtual machines are connected to the physical network.

1.2.1 Bridged Mode

insert image description here

  • In bridged mode, the virtual machine's network adapter is directly connected to the physical network adapter as if it were connected to another computer on the same local area network.

  • The virtual machine will get an IP address on the same network segment as the host, enabling it to communicate with other devices on the LAN. A virtual machine behaves almost indistinguishably from a physical computer in bridged mode.
    insert image description here

  • How to use bridge mode:

    • In VMwarethe virtual machine settings, select the virtual machine's network adapter and set it to bridged mode.
    • Make sure the host's network adapter is connected to an accessible LAN and has the correct IP configuration.
    • When the virtual machine is started, it gets an address available on the LAN IP, just like a physical computer.
  • Note: Bridge mode requires that the address of the virtual machine and the connected host network adapter are in the same network segment. After bridging, you can communicate with other hosts and access the Internet.


1.2.2 Host-Only Mode

insert image description here

  • In host mode, a private network is established between the virtual machine's network adapter and the host. Virtual machines can communicate with each other and with the host, but cannot communicate with external networks. This mode is useful for creating internal networks or for security testing between virtual machines.
    insert image description here

How to use host mode:

  • In the VMware virtual machine settings, select the virtual machine's network adapter and set it to host mode.
  • Make sure the host network adapter is also configured in host mode and is in the same virtual network
    insert image description here

insert image description here


1.2.3 NAT mode (Network Address Translation Mode)

insert image description here

  • In NAT mode, there is a virtual network router between the virtual machine's network adapter and the host's network adapter. The virtual machine communicates with the host through this virtual router, and then communicates with the external network through the host's network connection. The virtual machine shares the IP address of the host machine in NAT mode, so in the external network, the virtual machine appears as a device on the host machine.
    insert image description here

insert image description here
insert image description here

How to use NAT mode:

  • In the VMware virtual machine settings, select the virtual machine's network adapter and set it to NAT mode.
  • When the virtual machine is started, it gets a private IP address managed by the VMware virtual network editor, which is NAT'd by the host's network adapter to the external network.

1.3 Supplementary knowledge: DHCP

  • DHCP stands for "Dynamic Host Configuration Protocol" and is a network protocol used to automatically assign IP addresses and other network configuration information to computers and devices to enable them to communicate on the network.
  • The main function of DHCP is to simplify network management, allowing computers and devices to automatically obtain IP addresses and other necessary network parameters when they are connected to the network, without manual configuration.

DHCP works as follows:

  1. DHCP server : There is a device called a DHCP server in the network. It is responsible for managing IP address pools and other network configuration information.
  2. DHCP client : Other computers or devices, when connected to the network, can act as DHCP clients to request IP addresses and configuration information.
  3. IP address assignment : When a DHCP client joins the network, it broadcasts a specific DHCP request message, indicating that it needs an IP address. After receiving the request, the DHCP server selects an available IP address from the pre-configured IP address pool, and assigns it to the DHCP client.
  4. Other network configuration : In addition to the IP address, the DHCP server can also provide other network configuration information, such as default gateway, subnet mask, DNS server, etc.
  5. Lease management : The DHCP server will assign an IP address lease to the DHCP client, indicating the time during which the client can use the IP address. Before the lease expires, the DHCP client will send a lease renewal request to the DHCP server. If the request to continue using the IP address is approved, the lease will be extended.
  • By using DHCP, network administrators can more easily manage devices in the network and ensure that each device on the network has a unique IP address, avoiding conflicts and configuration errors that may be caused by manually configuring IP addresses. DHCP is widely used in modern computer networks, including home networks, corporate networks, and public networks.

Two steps and demo

2.1 Steps to use bridge mode

  1. Set the network adapter to be used by Vmware bridged mode, select the network adapter to be bridged, and then confirm
    insert image description here
  • Bridge mode: The default is to use the automatic bridge network adapter, and you can also choose a fixed network adapter.
  1. In the configuration of the virtual machine, choose to use bridge mode
    insert image description here
  • In a VMware virtual machine, when using bridged mode, you usually do not need to select the "Copy physical network connection state" option. This option is usually used in other network modes, such as NAT mode, to simulate the network connection status between a virtual router and the host.
  • In bridged mode, the network adapter of the virtual machine is directly connected to the physical network adapter, so the network connection status of the virtual machine will directly reflect the connection status of the physical network. In other words, the virtual machine's network connection will be consistent with the host's network connection status, and there is no need to set it separately.
  • In bridged mode, the virtual machine will share the same network connection state as the host, you just need to make sure the host's network adapter is connected to an accessible LAN.

2.2 Bridge Mode Result Demonstration

  • The virtual machine selects the bridge mode and starts querying the IP address
    insert image description here
  • Looking at the connected devices through the router, you can see that the virtual machine uses an available address on the LAN IP, just like a physical computer
    insert image description here

2.3 Use steps of host mode

  1. Select the host mode in vm to ensure that the virtual network card of the host mode is enabled, and you can view it in the control panel of the win system for details
    insert image description here
    insert image description here
  2. Set the virtual machine's network adapter to host host mode
    insert image description here
  3. Turn on the virtual machine and check whether the ip verification is successful

2.4 Demonstration results in host mode

insert image description here

  • If you use DCHP, if there is a network connection error, remember to set it to automatically obtain an IP
    insert image description here
  • Verification can only communicate with the host, but cannot access the external network
C:\Users\空月>ipconfig

Windows IP 配置


以太网适配器 Ethernet0:

   连接特定的 DNS 后缀 . . . . . . . : localdomain
   本地链接 IPv6 地址. . . . . . . . : fe80::9b82:caec:dd50:ded6%8
   IPv4 地址 . . . . . . . . . . . . : 192.168.107.128
   子网掩码  . . . . . . . . . . . . : 255.255.255.0
   默认网关. . . . . . . . . . . . . :

C:\Users\空月>ping 192.168.107.1

正在 Ping 192.168.107.1 具有 32 字节的数据:
来自 192.168.107.1 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.107.1 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.107.1 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.107.1 的回复: 字节=32 时间<1ms TTL=64

192.168.107.1 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms

2.5 NAT mode usage steps

  • Principle: NAT mode will create a virtual network Vmnet8 between the host and the virtual machine, requiring the system address of the virtual machine and the virtual network card of the physical machine to be in the same network segment. The address of the virtual machine is translated through VMnet8, so as to establish a connection with other hosts and access the external network through the physical network card!
  1. View the gateway address of vm's NAT mode
    insert image description here2. Configure the virtual network card address of the physical machine, which is located in the gateway of vm's nat mode
    insert image description here
  2. Configure the network adapter mode of the virtual machine to start
    insert image description here
  3. Start the virtual machine and configure static IP manually [because DCHP is not used]
    • Set IP, gateway, subnet mask, DNS server in the virtual machine
      insert image description here

2.6 NAT mode demonstration results

  1. The address of the host in the VMnet8 virtual network
    insert image description here
  2. Test the network in the virtual machine and access it normally
PS C:\Users\空月> ping baidu.com

正在 Ping baidu.com [39.156.66.10] 具有 32 字节的数据:
来自 39.156.66.10 的回复: 字节=32 时间=28ms TTL=128
来自 39.156.66.10 的回复: 字节=32 时间=28ms TTL=128
来自 39.156.66.10 的回复: 字节=32 时间=27ms TTL=128
来自 39.156.66.10 的回复: 字节=32 时间=28ms TTL=128

39.156.66.10 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 27ms,最长 = 28ms,平均 = 27ms
PS C:\Users\空月> ping 192.168.28.1

正在 Ping 192.168.28.1 具有 32 字节的数据:
来自 192.168.28.1 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.28.1 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.28.1 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.28.1 的回复: 字节=32 时间<1ms TTL=64

192.168.28.1 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms
PS C:\Users\空月> ping 192.168.1.23

正在 Ping 192.168.1.23 具有 32 字节的数据:
来自 192.168.1.23 的回复: 字节=32 时间=4ms TTL=128
来自 192.168.1.23 的回复: 字节=32 时间=3ms TTL=128
来自 192.168.1.23 的回复: 字节=32 时间=4ms TTL=128
来自 192.168.1.23 的回复: 字节=32 时间=3ms TTL=128

192.168.1.23 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 3ms,最长 = 4ms,平均 = 3ms

Three summary

  • This article mainly introduces and uses the three network configurations of VMWare virtual machines.
  • For the configuration of NAT mode in linux virtual machine, see centos7 set static IP
  • It is recommended to combine the two articles to eat together! !

Guess you like

Origin blog.csdn.net/yang2330648064/article/details/131489781