当前位置:首页 > 虚拟机 > 正文

虚拟机仅主机模式上网(虚拟机和主机如何分开上网)

VMware virtual machine settings for Internet access and communication with the local computer
After installing the VMware virtual machine, we often need the virtual machine to communicate with the local computer, or need the virtual machine to access the Internet. Let's take a look.
I am using VMware Workstation 12 version, and Centos7 is installed in the virtual machine.
VMware has three network connection modes: 1. Host-only mode: that is, host_only. This mode only allows the virtual machine to communicate with the local physical machine and does not allow access to the Internet; 2. NAT mode: this This mode retains the function of host mode only, but also allows the host to access the Internet; 3. Bridge mode: directly allows the virtual machine to use the local host's network card to access the Internet.
After installing VMware, the software will create two virtual network cards in the system, namely VMnet1 and VMnet8. VMnet1 is used in host-only mode, and VMnet8 is used in NAT mode. This must be distinguish! ! !
NAT mode setting: When I set up the network, I set the IP address segment to 192.168.111.0. This can be set at will as long as there is no conflict. 1. Check the address of the local computer's virtual network card: 192.168.111.1 Subnet mask: 255.255.255.0 The gateway does not need to be set. Note: The two VMnet network cards need to be set to different network segments. They can be set at will. The default is VMware Already configured and ready to use.
2. Check the VMware virtual network editor settings in the VMware toolbar---Edit---Virtual Network Editor. .Subnet IP: refers to the subnet IP segment, not a specific IP address, but 192.168.111.0. Subnet mask: the same as the subnet mask set by VMnet. Note: By default, VMware has been set and can be used directly.
3. Check the DHCP of the virtual network editor. The starting IP address should exclude the IP in VMnet. Starting IP address: 192.168.111.5 Ending IP address: 192.168.111.254. Note: It is best to exclude a few more starting IP addresses.
4. NAT settings, please note that you need to set the following settings here, and exclude them in DHCP. Gateway: 192.168.111.2
4. Set the virtual machine Internet access method, in the tool Select the host-only mode in the virtual machine---Settings---Network Adapter column; 5. Set the network configuration in the virtual host directly to automatically obtain
Host-only mode: Settings and NAT mode settings The same, except that there is no need to set up NAT in the virtual network editor, and select the host-only mode when setting the Internet access mode
Bridge mode: This mode directly uses the physical network card to obtain the address, and directly sets the Internet access mode. Select the bridge mode only. Note: If there is a physical network card in the system and the virtual machine cannot access the Internet, you need to select which network card in the bridge in the virtual network editor

What are the network models of vmwareworkstation virtual machines?
When using VMwareWorkstation to create a virtual machine, you can choose which virtual network card to use and which connection method according to your needs. There are three types by default: VMnet0 (bridged network), VMnet1 (host network only) and VMnet8 (NAT network). Of course, you can add 7 virtual network cards from VMnet2 to VMnet7 and VMnet9 as needed. Let’s introduce it below:
Open the virtual machine, and then open the virtual network editor being edited in the menu bar. As shown below. I saw that there are three modes in total: VMnet0, VMnet1, and VMnet8. So what do these three modes represent and the mode and type of connection respectively.
1. Let’s talk about the simplest VMnet1 first. This mode is called host-only mode.
The implication is that the virtual machine can only contact the host and the virtual machines on the host. See this picture for explanation. VMnet1 is equivalent to a network card, or a switch. After assigning an address to a virtual machine, each virtual machine can only access its own host and its own virtual machine. For example, in this diagram, the LAN switch is a real switch. Virtual machine A1, virtual machine A2 and host A can access each other. Virtual machine B and virtual machine B1 can also access each other. However, B and B1 on the left side of the dotted line cannot access each other from A, A1, and A2 on the right side of the dotted line.
2. NAT mode: This is for the VMnet8 of the virtual machine.
This mode is exactly the same as the NAT mode in the server. You need to have a detailed understanding of NAT mode. For example, in a large server system, there are web servers, FTP servers, database servers, etc. These are all mapped out through the intranet address. That is, one port corresponds to one service. The other party can only come in through a specific port number. Otherwise, the host cannot be accessed. In this figure, virtual machines A1 and A2 are just equivalent to a specific server of host A. They can access host B, but cannot access virtual machine B1. Similarly, virtual machine B1 cannot access virtual machines A1 and A2. One thing to remember about this mode is one-way access.
3. Bridge mode: This corresponds to VMnet0.