Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Deeply understand the Internet mode of VMware virtual machine in practice: NAT mode

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

0. Description

This blog post is one of a series of "in-depth understanding of the Internet mode of VMware virtual machines in practice": NAT mode.

VMware virtual machine is indispensable in our learning process, whether it is installing the Linux operating system for learning, building various network services, or for cluster testing, cloud computing platform OpenStack, etc., it can be said that the VMware virtual machine has brought us great convenience, the most intuitive benefit is that we can save a lot of money used to buy a variety of devices, but also achieve the purpose of learning various technologies.

However, as long as it involves communication between the host and the operating system in the VMware virtual machine, or the communication between the operating systems installed in the VMware virtual machine, it is inseparable from the content of the computer network. In fact, let each operating system in the virtual machine communicate with the network, or let our host communicate with the virtual machine. It is an inseparable topic that we usually use VMware virtual machine to test various services.

Therefore, it is necessary to understand the more in-depth computer network communication principles among the various Internet access methods provided to us by the VMware virtual machine, so that the problems on the network can be easily solved for all kinds of environments we need to build, instead of looking for all kinds of materials everywhere, and this will be of great help to the experimental environment involving the communication of multiple devices in the future.

The blogger has deeply studied the network knowledge of Huawei and Cisco, and passed Huawei's highest ICT certification HCIE-RS last year, so this blog is written from a network engineer's point of view to understand the communication principles of various Internet access modes in the VMware virtual machine. Although it is still difficult to fully understand some of the details, I believe it can still bring great help to all friends.

The writing way of this blog is still based on theory, combined with practical operation, in practice in-depth understanding of the various Internet access methods of the VMware virtual machine.

There are three ways of VMware virtual machine surfing the Internet: NAT, bridging and host-only mode. This article introduces NAT mode.

1. Experimental environment

The blogger's experimental environment is as follows:

Host operating system: Windows 7

VMware Workstation version: 12.5.2 build-4638234

Virtual machine operating system: Windows 7

Virtual machine operating system Internet access: NAT mode

Note: in order for the later test to be normal, be sure to turn off the firewall function of the operating system of the host and virtual machine.

For the setting of the Internet mode, you can refer to the following illustration:

Windows 7's Internet access settings:

Theoretical knowledge of 2.NAT pattern

When the Internet access mode of our virtual machine is set to NAT mode, the connection relationship among virtual machines, hosts and network cards can be shown in the following figure:

In fact, after reading the above graphical analysis, the overall network topology is very clear, in the next steps, through our experimental environment to verify.

3. Deeply understand the network principle of NAT mode in practice

In the experimental environment, we can see that we surf the Internet through NAT. When the NAT mode is set, check the IP address information in the virtual machine operating system Windows 7:

At this time, you will find that there is no problem with the communication between the host and the virtual machine:

On the host, ping the virtual machine:

So why can you communicate normally? And why is the network segment of the IP address in the virtual machine 10.0.0.0 Universe 24?

When using NAT mode to surf the Internet, VMware will automatically assign IP addresses to our virtual machine operating system. At this time, there is a DHCP server inside the virtual machine, and the assigned address network segment can be set in VMware.

Select "Edit"-"Virtual Network Editor" in VMware Workstation, and you can set it:

As you can see from the above, the network segment we set here is 10.0.0.0swap 24.

In addition, our host communicates with the virtual operating system through the virtual network card VMnet8. You can see this virtual network card in the network settings of the host:

Because this virtual network card is used to communicate with the virtual machine operating system, the address assigned to it is also 10.0.0.0and24, so you can check its address:

So in fact, when our host communicates with the virtual machine operating system, the source address 10.0.0.1 is used to send packets to the operating system of the virtual machine. We can ping this address on the virtual machine operating system, and we will find that there is no problem with communication:

So where is the address of the gateway 10.0.0.2 for the virtual machine operating system?

In fact, it corresponds to the virtual Nic address of the NAT server in our network diagram above, but this address can only be seen in the virtual machine operating system.

So put the address and network segment information mentioned above into our diagram, as follows:

In this way, the overall network information is very clear, and as you can see above, the address of the host physical network card is 192.168.1.100 Universe 24, which is the IP address assigned to me by the local area network where my laptop is located.

Through the above graphical analysis, we can have a clear understanding of the network communication of the virtual machine operating system:

When the virtual machine communicates with the host, it actually communicates with the addresses 10.0.0.1max 24 and 10.0.132max 24.

When the virtual machine communicates with the external network: the virtual machine first sends the data to the gateway 10.0.0.2Universe 24, and then translates the address to 192.168.1.100amp24 through the NAT server, and then communicates with the external network.

If the virtual network card Vmnet8 is disabled, it will not affect the virtual machine access to the Internet, but the communication between the host and the virtual machine will be affected, as can be seen from the diagram above.

In this way, the process of communication is very clear! In addition, if we have many virtual machines and access the Internet in NAT mode, then in fact, these virtual machines are all located in the same local area network, then the communication between the virtual machine and the host and the access to the external network of the virtual machine is the same as the above process, while the communication between the virtual machine and the virtual machine is the communication in the same local area network, so there is no problem. All this will become much clearer.

It should be added that for the DHCP services and NAT services provided by the virtual machine, you can actually see these services on the host where we installed VMware Workstation:

In this way, it can correspond to our theory to a certain extent.

4. What should we do next?

You can consider having multiple virtual machines, and as mentioned above, you can try to test their connectivity and verify the above diagram (especially important), but only if you have some knowledge of networking.

5. Application in practice

First of all, the first point is that when our virtual machine has network problems, we need to understand the topology of the network before troubleshooting, so the above content provides us with very good theoretical and practical knowledge.

In addition, if we can build various services and do all kinds of tests on the premise of understanding these network knowledge, we can achieve a state of confidence, instead of "looking at flowers in the fog and looking at the moon in the water." accordingly, in such continuous attempts, our comprehensive operation ability will certainly become stronger.

However, it is still necessary to note that the above illustration is still for reference, and many of the details need to know the details of VMware Workstation's network virtualization in order to really understand clearly, but in any case, the above content for network communications, or can bring us a lot of help, I sincerely hope to help you!

Due to the limited capacity and time, if you find any problems, please point them out in time.

Add:

For network troubleshooting, you can refer to a blog post previously written by the blogger: "explanation of Network debugging".

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report