Detailed explanation of three network modes of VMware virtual machine NAT (address translation mode)

2. NAT (address translation mode)

We just mentioned that if your network IP resources are in short supply, but you want your virtual machine to be able to connect to the Internet, NAT mode is the best choice at this time. NAT mode enables virtual machines to connect to the Internet with the help of virtual NAT devices and virtual DHCP servers. Its network structure is shown in the following figure:

NAT mode

In NAT mode, the host network card is directly connected to the virtual NAT device, and then the virtual NAT device and the virtual DHCP server are connected to the virtual switch VMnet8, thus realizing the networking of virtual machines. Then we will feel very strange, why do we need the virtual network card VMware Network Adapter VMnet8? It turns out that our VMware Network Adapter VMnet8 virtual network card is mainly to realize the communication between the host and the virtual machine. We can verify this in a later setup step.

First, set the NAT mode option in the virtual machine, open vmware, click "Virtual Network Editor" under "Edit", and set the NAT parameters and DHCP parameters.

Virtual Network Editor

NAT parameters

DHCP parameters

Change the network connection mode of the virtual machine to NAT mode, and click "Edit virtual machine settings".

Edit virtual machine settings

Click on "Network Adapters" and select "NAT Mode"

NAT mode

Then boot the system, edit the network card configuration file, the command is vi /etc/sysconfig/network-scripts/ifcfg-eth0

Edit the network card configuration file

The specific configuration is as follows:

Specific placement

After editing, save and exit, then restart the virtual machine network card, dynamically obtain the IP address, and use the ping command to ping the external network IP to test whether it can be connected to the Internet.

Test if you can connect to the Internet

Before, we talked about the role of the VMware Network Adapter VMnet8 virtual network card, so let's test it now.

Virtual NIC disabled

Whether it can be pinged

It seems that the virtual machine can connect to the external network, not through the VMware Network Adapter VMnet8 virtual network card, so why have this virtual network card?

Earlier we said that the role of VMware Network Adapter VMnet8 is the communication between the host and the virtual machine. Next, we will use the remote connection tool to test it.

Remote connection tool test

Then, after enabling VMware Network Adapter VMnet8, it was found that remote tools could connect to the virtual machine.

Well, this is the NAT mode, which uses a virtual NAT device and a virtual DHCP server to connect the virtual machine to the external network, and the VMware Network Adapter VMnet8 virtual network card is used to communicate with the virtual machine.

Guess you like

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