VMware virtual machine three network mode Detailed

A, VMware several common virtual device

Open the VMware -> Edit (Edit) -> VirtualNetworkEditor (Virtual Network Editor), as shown:

VMnet0: a virtual switch in virtual bridged network

VMnet1: a virtual switch in the Host-Only virtual network

VMnet8: a virtual switch in the virtual NAT network

Meanwhile, after a VMware virtual machine installation, connection dialog extra two virtual NICs on the local host network, as follows:

VMware Network AdepterVMnet1: Host for the virtual network adapter to communicate with Host-Only virtual network

VMware Network Adepter VMnet8: Host for the virtual network adapter to communicate with the NAT virtual network

But if you are installing a VirtualBox virtual machine, it will only be a virtual network card: VirtualBox Host-Only Network, can only be used to host virtual network connection mode standalone host, the host can not connect to a virtual machine NAT network, which is with Vmware different.

Second, the three network models introduced

2.1 bridge bridge mode

In this mode, VMware virtual out of the operating system is like a LAN stand-alone host, it can access any machine within the network. You need to manually configure the IP address, subnet mask of the virtual system, but also to the host machine and the same network segment, so the virtual machine and host systems to communicate. Also, because the virtual host system is an independent system LAN, then you can manually configure its TCP / IP configuration information to enable access to the Internet through a local area network gateway or router.

Host, other LAN hosts, virtual machines, all three can visit each other.

First, set the network mode selection bridge, VMware in the Vmware -> VM (Virtual Machine check that you have created) -> Setting (Settings) -> NetworkAdapter (network adapter)

在 Vmware 中选择桥接网卡:VMware --> Edit(编辑)--> VirtualNetworkEditor(虚拟网络编辑器),在"桥接到"下拉框中选择要使用的网卡,可以是有线或者无线网卡。

然后查看主机对应网卡的 IP 信息,如下:

然后配置虚拟机中 CentOS 的 IP 地址信息,如下:

主机可以连接到虚拟机,如下:

也可以在虚拟机中访问外网和主机,如下:

2.2 NAT 网络地址转换

使用 NAT 模式,就是让虚拟系统借助 NAT(网络地址转换)功能,通过宿主机器所在的网络来访问公网。也就是说,使用 NAT 模式可以实现在虚拟系统里访问互联网,但前提是主机可以访问互联网。NAT 模式下的虚拟系统的 TCP/IP 配置信息是由 VMnet8(NAT)虚拟网络的 DHCP 服务器提供的,无法进行手工修改,因此虚拟系统也就无法和本局域网中的其他真实主机进行通讯。采用 NAT 模式最大的优势是虚拟系统接入互联网非常简单,不需要进行任何其他的配置,只需要主机器能访问互联网即可。这种情况下,主机可以 ping 通虚拟机,虚拟机也能 ping 通主机。

主机,局域网其他主机,虚拟机,三者中主机和虚拟机可互相访问,但是局域网其他主机和虚拟机不能互访。(如果是 VirtualBox,三者均不能互访)

首先设置选择虚拟机的网络模式为 NAT,VMware --> VM(选中自己创建的虚拟机) --> Setting(设置) --> NetworkAdapter(网络适配器)

然后设置 VMnet8 的 IP 地址及网关 VMware --> Edit(编辑) --> VirtualNetworkEditor(虚拟网络编辑器)

点击 "NAT设置"按钮,如下:

点击 "DHCP设置"按钮,如下:

默认使用的 dhcp,无须自己配置 IP 信息,当然也可以自己将其设置为 static 静态 IP,如下:

 虚拟机和主机可以互相访问,如下:

2.3 Host-Only 独立主机模式

在 Host-Only 模式下,虚拟网络是一个全封闭的网络,它唯一能够访问的就是主机,当然多个虚拟机之间也可以互相访问。其实 Host-Only 网络和 NAT 网络很相似,不同的地方就是 Host-Only网络没有 NAT 服务,所以虚拟网络不能连接到 Internet。主机和虚拟机之间的通信是通过 VMware Network Adepter VMnet1 虚拟网卡来实现的。此时如果想要虚拟机上外网则需要主机联网并且网络共享。

首先设置选择虚拟机的网络模式为 Host-Only,VMware --> VM(选中自己创建的虚拟机) --> Setting(设置) --> NetworkAdapter(网络适配器)

然后设置 VMnet1 的 IP 地址及网关 VMware --> Edit(编辑) --> VirtualNetworkEditor(虚拟网络编辑器)

设置静态的 Host-Only 模式的 IP 地址,如下:

主机可以访问该虚拟机,如下:

但是虚拟机无法访问主机,也不能访问互联网,除非本地主机共享网络。

综上,在 VMware 的三种网络模式中,NAT 模式是最简单的,基本不需要手动配置 IP 地址等相关参数,桥接模式则需要额外的 IP 地址,独立主机模式建立于主机的私有网络。

参考资料

虚拟机三种网络模式&桥接模式设置步骤

VMware虚拟机三种联网方式(图文详细解说)

Guess you like

Origin www.cnblogs.com/cnjavahome/p/11266931.html
Recommended