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

vm虚拟机三种模式(vm虚拟机安装)

About the settings for the VM virtual machine to access the physical host and the external network--NAT mode
There are three network modes selected by the VM, bridge mode, NAT mode, and host-only mode. Regarding the three mode selections, you can Baidu yourself. There are many methods on the Internet, but the one that suits you is the best. This article records personal operation notes and uses NAT mode to provide a solution for interoperability between virtual machine Linux, physical host, and external network.
--->Preparation<---: 0. Check the IP of the current physical host, open cmd, enter ipconfig/all, you can check the IP address information, gateway, and corresponding to the physical host. Subnet mask.
1. Remove VMnet0 (bridge mode) and VMnet1 (only host mode), leaving only VMnet8, as shown below:
2. You need to set the subnet for VMnet8 mode The IP address of the virtual host is not in the same subnet as that of the physical host, as shown in the figure:
3. Under Net settings, set the gateway network segment of the virtual host to be not in the same network segment as that of the physical host. Confirm and save, as shown in the figure below. :
4. Set the virtual machine to NAT mode, as shown below:
5. Set the fixed IP of Linux and open the path: vim/etc/sysconfig/network-scripts /ifcfg-ens33 (ifcfg-ens33 may not exist, please see the specific virtual machine configuration file), as shown in the figure:
Note: BOOTPROTO="static"
6. Restart the network: systemctlrestartnetwork. Then use xshell to connect, try to communicate between the virtual machine and the physical host (if you can connect to xshell, it means interoperability), the virtual machine pings Baidu, ok...
---Updated on November 23, 2020
About the problem that the ssh tool is slow to connect to the virtual machine:
1. vi/etc/ssh/sshd_config
2. Change UseDNSyes, Change to UseDNSno
3. Restart the ssh service
servicesshdrestart
e

Three network modes of virtual machines (bridging, NAT, Host-only)
Bridged network refers to the local physical network card and virtual network card being bridged through the VMnet0 virtual switch. The virtual network card and physical network card are on the network. If they are in the same position on the topology map, then the virtual network card and the physical network card are equivalent to being in the same network segment, and the virtual switch is equivalent to a switch in the real network, so the IP addresses of the two network cards need to be set to the same network segment.
Since the virtual machine and the host machine have the same status in the network in bridge mode, when other PCs in the LAN want to access the virtual machine, they must choose bridge mode.
For example, there is a router in the dormitory, the lanip of the route is 192.168.1.1, and the subnet mask is 255.255.255.0. At the same time, there are three PCs in the dormitory, and their IPs are automatically obtained. Assume that the IPs of the three PCs are:
pc1: 192.168.1.100 pc2: 192.168.101 pc3: 192.168.102

Then the addresses that the virtual machine can set are 192.168.1.2--192.168.1.99 and 192.168.1.103--192.268.1.204. You can set the IP address of the virtual machine to: 192.168.1.98, so that other PCs in the LAN can access the virtual machine through this IP. If the virtual machine still needs to access the Internet, you also need to configure the routing address of the virtual machine: 192.168.1.1, and then configure a DNS server for the virtual machine. You can set it to Google's DNS server: 8.8.8.8. Then, the virtual machine can access the Internet. .
In NAT mode, the virtual machine uses the NAT (Network Address Translation) function to access the public network through the network where the host machine is located.
In NAT mode, the network card of the virtual machine and the network of the physical network card are not in the same network. The network card of the virtual machine is a virtual network provided by vmware.
Comparison between NAT and bridging:
1. Since the NAT network is in a virtual network provided by vmware, other hosts on the LAN cannot access the virtual machine, and the host The host can access the virtual machine, and the virtual machine can access all hosts on the LAN, because the real LAN is the NAT virtual network compared to the NAT virtual network;
2. Both bridge mode and NAT mode are available To access the external network, multiple virtual machines can access each other.
If you build a virtual machine for your own use only and do not need to be used by others on the LAN, then you can choose NAT. After all, the TCP/IP configuration information of the virtual system in NAT mode is provided by VMnet8 ( NAT) provided by the DHCP (automatically assigned IP) server of the virtual network. As long as the network configuration of the virtual machine is DHCP, then you do not need to perform any other configuration. You only need the host machine to access the Internet, and then the virtual machine can Connected to the Internet.
If you want to establish multiple virtual machine clusters, the host may be a laptop and the IP address is not fixed. In this application scenario, we need to use NAT mode. However, virtual machines need to access each other. DHCP is used by default. Every time the virtual machine is restarted, the IP may change, so we need to manually set the IP address of the virtual machine (by checking the subnet IP and subnet mask). To set the virtual machine IP and set the routing address, which is the gateway IP, as for dns, it can be set to 8.8.8.8).
In Host-Only mode, the virtual network is a fully closed network, and the only thing it can access is the host. In fact, the Host-Only network is very similar to the NAT network. The difference is that the Host-Only network does not have a NAT service, so the virtual network cannot be connected to the Internet. Communication between the host and the virtual machine is achieved through the VMwareNetworkAdepterVMnet1 virtual network card.
The purpose of Host-Only is to establish an internal network isolated from the outside world to improve the security of the internal network. This feature may not mean much to ordinary users, but large service providers often take advantage of this feature.
Among the three network modes of virtual machines, NAT mode is the simplest, and there is basically no need to manually configure IP addresses and other related parameters. As for the bridge mode, it requires an additional IP address. If it is in an intranet environment, it is easy. If it is ADSL broadband, it will be more troublesome. ISPs generally will not generously provide an additional public IP address.
Reference article address: Examples to explain the three network modes of virtual machines (bridging, nat, host-only)-ggjucheng-blog garden
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. Take a look at this picture 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.