Configure the Virtual Machine network in three ways

Source: Internet
Author: User
I. Differences between the three types of networks

1. vmnet0

Vmnet0 is actually a virtual bridge. This bridge has several ports, one for connecting your host, and the other for connecting your virtual machine. Their locations are equal, no one is the gateway. So in bridged mode, you can make the virtual machine the same as your host.

2. vmnet1

Vmnet1 is a host-only network mode, which is used to establish an isolated network environment. vmnet1 is also a virtual switch, and a port of the switch is connected to your host, another port is connected to the virtual DHCP server (actually a component of VMware), and the remaining port is connected to the virtual machine. The virtual nic "VMWare virtual Ethernet adapter for vmnet1" serves as the gateway interface of the Virtual Machine and provides services for the virtual machine. After the VM is started, if you use the ipconfig command, you will clearly see that your default gateway is pointing to the IP address of the "vmw are virtual Ethernet adapter for vmnet1" Nic. No route is provided here, mainly because no NAT service is provided, so that virtual machines cannot access addresses outside the CIDR Block specified in host-only mode.

3. vmnet8

Vmnet8 is a NAT method and the simplest networking method. It is connected to the vmnet8 vswitch from the host's "VMWare virtual Ethernet adapter for vmnet8" virtual Nic, another port of the vswitch is connected to the virtual Nat server (which is also a VMware component), a port is connected to the virtual DHCP server, and other ports are connected to the virtual machine, the Virtual Machine gateway is the machine where the "VMWare virtual Ethernet adapter for vmnet8" Nic is located, that is, your host machine.

Ii. repost the record of instructor Wu

The role of a virtual machine is to allow more operating systems to be installed under the existing operating system, physically isolated from each other, and form a network, so as to maximize the performance of the computer. As a free virtual machine, virtualbox is very useful. Similarly, there is VMWare, which is also a very useful virtual machine, and the operation is very similar. The following uses Network Connection Methods in vbox as an example.

2.1 network knowledge

Access to computers in the network is directed by IP addresses. It's like our ID card number. We can identify a person only. IP addresses are used to differentiate computers in the network. Therefore, IP addresses in the same network (accurately speaking, "network segments,IP addresses cannot be the same. If the same IP address exists in the same network, the network may fail to be connected or the network may be disconnected frequently.

Networks are managed in segments. Take the LAN as an example. Our common network segment is 192.168.1.xxx. Our IP address is to divide XXX into numbers from 1 to 254. If the IP addresses of multiple computers are preceded by 192.168.1, the IP addresses belong to the same network segment and can communicate with each other. If the IP address of one machine is 192.168.1.100 and the IP address of the other machine is 192.168.3.100, communication is not allowed under normal circumstances (there is a way to solve this problem, we will not discuss it ). Therefore, when setting a virtual machine, consider whether the same network segment is used.

2.2 how do I know the IP address of my computer?

In Windows, run ipconfig in the command line. In Linux, run ifconfig in the command line.

2.3 How can I determine whether to communicate with the other party?

The simplest way is to run the ping command. In either Windows or Linux, you can run "ping the IP address of the other party" in the command line"

2.4 labs

(1) Querying IP addresses

In Windows, you can run the ipconfig command on the command line. Figure 1 shows the result of my execution.

Figure 1

(2) view the information in the network connection, as shown in figure 2.

 

Figure 2

  • As you can see, there are a total of four network settings. Where:
  • The first is the wireless network, which is not used and is not displayed;
  • The second is the local connection, that is, the address information corresponding to the NIC interface on the notebook, which is the most common;
  • The third is the virtual network of virtualbox. After we install virtualbox, a virtual network card will be generated in the network connection. This is the network of the network card;
  • Fourth, broadband Internet access is available at home.

There are many network connections. For those that have already been used, add the numbers 1-4 in Figure 2. These numbers represent the networks corresponding to different IP addresses in Figure 1. If a network is disabled and displayed as gray, no corresponding IP address is displayed when ipconfig is executed.

(3) virtualbox provides three most common network connection methods

Virtualbox provides three most common Network Connection Methods: Network Address Translation (NAT), bridging network adapter, and host-only adapter. 3.

Figure 3

In section 2.5, what are the meanings of the three network access methods and how to use them.

(1) Network Address Translation (NAT)

This access mode means that the virtual machine does not occupy the IP address of the LAN where the host is located. By using the host's NAT Function to access the LAN and the Internet, the virtual machine can access other computers in the LAN, however, other computers do not know the existence of virtual machines.

In this mode, the virtual machine does not need to set a static IP address. You only need to use the DHCP function to automatically obtain the IP address. The advantage of this mode is that you can use the network card of the host to access the Internet without occupying more IP addresses. In the age when IPv4 was tense, Nat was invented. Therefore, most of the Internet users used this method.

(2) Bridging NICs

This access mode refers to the network connection mode of the host. Virtual machines and hosts share the same network with other computers in the same LAN. If the host can access the Internet without restrictions, the virtual machine can also access the internet. If the host is bound to a Mac to access the Internet, the virtual machine must be bound to a Mac to access the Internet.

In Figure 2, one of the 1, 2, and 4 may be used. The specific method depends on how the host accesses the internet. Now, if we use the 2nd Network Connection Methods in Figure 2, it means that in Figure 1 we use the network connection method in 2nd, and the network segment is 192.168.1.xxx. Therefore, we must set the IP address of the VM to 192.168.1.xxx, where XXX is a number ranging from 1. You can set an IP address that is never used by other computers. How do I know which IP address is not used by others? Suppose you want to use the IP address 192.168.1.88, you can run the command "Ping 192.168.1.88". If the returned content is shown in figure 4, no one uses this IP address.

Figure 4

If you run the command "ping an IP address" and return content similar to Figure 5, it indicates that the IP address is being used in the network and you cannot use it.

 

Figure 5

The advantage of this mode is that virtual machines can easily access other computers in the LAN and access the internet.

(3) only host-only adapters

This access mode means that the virtual machine and the host form a separate LAN, Which is isolated from the current network of the host. In this network connection mode, the 3rd networks in Figure 2 cannot be stopped. Otherwise, this mode cannot be used. To communicate with the host, you must set an IP address and the host in the same network segment. The 3rd IP addresses in Figure 1 are the Host IP addresses and the network segment is 192.168.56.xxx. This means that the IP address of the VM should also be in this CIDR block. The advantage of this mode is that the virtual machine network can be physically isolated from the network where the host is located, but the disadvantage is that it cannot easily access the internet.

Note: This article from the wisdom of the podcast Wu Chao teacher's personal space: http://www.superwu.cn/2013/10/06/653/

Configure the Virtual Machine network in three ways

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.