当前位置:Linux教程 - Linux文化 - vmware网络设置(三):理解虚拟网络的类型

vmware网络设置(三):理解虚拟网络的类型


很多朋友都用vmware来测试不同的系统,我结合自己的经验谈一下对网络设置的理解,不对的地方请指正。 bridge: screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs.chinaunix.net/forum/uploadfile/bridged_1.gif');}" onmousewheel="return imgzoom(this);"> 这种方式最简单,直接将虚拟网卡桥接到一个物理网卡上面,和linux下一个网卡 绑定两个不同地址类似,实际上是将网卡设置为混杂模式,从而达到侦听多个IP的能力。 在此种模式下,虚拟机内部的网卡(例如linux下的eth0)直接连到了物理网卡所在的网络上,可以想象为虚拟机和host机处于对等的地位,在网络关系上是平等的,没有谁在谁后面的问题。 使用这种方式很简单,前提是你可以得到1个以上的地址。对于想进行种种网络实验的朋友 不太适合,因为你无法对虚拟机的网络进行控制,它直接出去了。 nat方式: screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs.chinaunix.net/forum/uploadfile/nat_1.gif');}" onmousewheel="return imgzoom(this);"> 这种方式下host内部出现了一个虚拟的网卡vmnet8(默认情况下),如果你有过 做nat服务器的经验,这里的vmnet8就相当于连接到内网的网卡,而虚拟机本身则相当于运 行在内网上的机器,虚拟机内的网卡(eth0)则独立于vmnet8。 你会发现在这种方式下,vmware自带的dhcp会默认地加载到vmnet8界面上,这样虚拟机就可以使用dhcp服务。更为重要的是,vmware自带了nat服务,提供了从vmnet8到外网的地址转 换,所以这种情况是一个实实在在的nat服务器在运行,只不过是供虚拟机用的。 很显然,如果你只有一个外网地址,此种方式很合适。 hostonly: screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs.chinaunix.net/forum/uploadfile/host-only_1.gif');}" onmousewheel="return imgzoom(this);"> 这应该是最为灵活的方式,有兴趣的话可以进行各种网络实验。和nat唯一的不同的是,此 种方式下,没有地址转换服务,因此,模认情况下,虚拟机只能到主机访问,这也是hostonly的名字的意义。 默认情况下,也会有一个dhcp服务加载到vmnet1上。这样连接到vmnet1上的虚拟机仍然可以设置成dhcp,方便系统的配置. 是不是这种方式就没有办法连接到外网呢,当然不是,事实上,这种方式更为灵活,你可以使用自己的方式,从而达到最理想的配置,例如: a。使用自己dhcp服务:首先停掉vmware自带的dhcp服务,使dhcp服务更为统一。 b。使用自己的nat,方便加入防火墙。windows host可以做nat的方法很多,简单的如windows xp的internet共享,复杂的如windows server里的nat服务。 c. 使用自己的防火墙。因为你可以完全控制vmnet1,你可以加入(或试验)防火墙在vmnet1和外网的网卡间。 从以上可以看出,hostonly这种模式和普通的nat server带整个内网上网的情形类似,因此你可以方便的进行与之有关的实验,比如防火强的设置等。 我的有关具体网络设置的另外两篇文章 (vmware 配置实例-linux host + windows guest 和 vmware 网络配置实例二windows host + linux guest )也是以此配置为基础的。


摘自:chinaunix.net