存档

你当前正在浏览 The Utopia 中分类为“虚拟化”的文章存档。

分类为“虚拟化”的文章存档

使用 VMware 和 Dynamips 搭建广域网测试环境

前言:本文于2006年10月发布于虚拟机之家(www.xuniji.com),原帖地址为:http://www.xuniji.com/forum/view.asp?id=5701

最近网上出来个好东西,叫 Dynamips,又称“Cisco 7200 模拟器”,其原理大致和 VMware一致,也是模拟硬件来实现的,所以其完美性可想而知。而且,Dynamips 也支持网卡的桥接模式,这样的话可以和主机的以太网卡进行通信,使用 OmniPeek 可以看到路由器的协议数据包。基于此,萌发了使用 VMware + Dynamips 来模拟广域网实验环境的想法,这样,Cisco 工程师们也可以在单机环境下进行7层实验了,比如Q.o.S、7层安全等实验,的确是一个很激动人心的功能。

阅读全文 »

在 VMware 中使用 Windows Server 2003 和 Linux 混合运行 RIP 路由协议

前言:本文发布于2006年6月,地址为:http://www.xuniji.com/vmware/view.asp?id=100

关于 RIP 协议,就不多说了,本例中使用的 RIP 协议是 Version 2 的,支持认证、MD5 加密、VLSM、CIDR等,在这里使用 Version 2 而不使用 Version 1,是因为 Windows Server 2003 和 Linux 均不支持 RIPv1。由于RIP 协议是国际标准,各个厂商都会有支持。所以不管我是用 Windows 还是 Linux 或是 UNIX,都应该可以顺利地运行 RIP 协议。

这里是本例中所使用的拓扑图:

阅读全文 »

理解 VMware 的3种网络模型

前言:本文最早发布于2005年10月,位于vmware.cn,现在原帖地址已经无法找到。
很多朋友都曾问到关于Guest和Host互联,其实这并不是一件困难的事情,只要能够理解VMware的网络模型即可,今天结合着我的虚拟机,来详细介绍一下VMware的3种网络结构。
在说到VMware的网络模型之前,先说一下VMware的几个虚拟设备:
■    VMnet0:这是VMware用于虚拟桥接网络下的虚拟交换机;
■    VMnet1:这是VMware用于虚拟Host-Only网络下的虚拟交换机;
■    VMnet8:这是VMware用于虚拟NAT网络下的虚拟交换机;
■    VMware Network Adapter VMnet1:这是Host用于与Host-Only虚拟网络进行通信的虚拟网卡;
■    VMware Network Adapter VMnet8:这是Host用于与NAT虚拟网络进行通信的虚拟网卡;
■ 关于桥接网络:
拓扑图:
Host的物理网卡和Guest的网卡在VMnet0交换机上通过虚拟网桥进行桥接,这也就是说,我的物理网卡和我的Guest的虚拟网卡(注:这个虚拟网卡不等于VMware Network Adapter VMnet1或者VMware Network Adapter VMnet8)处于同等地位,此时的Guest就好像我的Host所在的一个网段上的另外一台机器。打个比方来说:
我的Host的物理网卡配置如下:
IP地址为手工指定方式,网关为192.168.0.1,那么我的Guest就应该和我的Host处于同一个网段,它的配置可为:
同样,IP地址也为手工指定方式,网关也为192.168.0.1,这样的话,IP地址为192.168.0.2的Host和IP地址为192.168.0.158的Guest就可以互通了:
当然,Guest所配置的IP地址一定要在192.168.0网段没有被占用,而且我的网络管理员允许我来使用这个IP地址。如果在192.168.0网段,存在DHCP服务器,那么Host和Guest都可以把IP地址获取方式设置为DHCP方式。
VMware中对于Bridged网络的定义(引用自VMware GSX Server User’s Manual):
Bridged networking connects a virtual machine to a network using the host computer’s Ethernet adapter.
Bridged networking is set up automatically if you select Use bridged networking in the New Virtual Machine Wizard or if you select the Typical setup path. This selection is available on a Linux host only if you enable the bridged networking option when you install GSX Server.
If your host computer is on an Ethernet network, bridged networking is often the easiest way to give your virtual machine access to that network. On a Windows host, you can use bridged networking to connect to either a wired or a wireless network. On a Linux host, you can use bridged networking to connect to a wired network.
If you use bridged networking, your virtual machine needs to have its own identity on the network. For example, on a TCP/IP network, the virtual machine needs its own IP address. Your network administrator can tell you whether IP addresses are available for your virtual machine and what networking settings you
should use in the guest operating system. Generally, your guest operating system may acquire an IP address and other network details automatically from a DHCP server, or you may need to set the IP address and other details manually in the guest operating system.
If you use bridged networking, the virtual machine is a full participant in the network. It has access to other machines on the network and can be contacted by other machines on the network as if it were a physical computer on the network.
Be aware that if the host computer is set up to boot multiple operating systems and you run one or more of them in virtual machines, you need to configure each operating system with a unique network address. People who boot multiple operating systems often assign all systems the same address, since they assume only one operating system will run at a time. If you use one or more of the operating systems in a virtual machine, this assumption is no longer true.
If you make some other selection in the New Virtual Machine Wizard and later decide you want to use bridged networking, you can make that change in the virtual machine settings editor (VM > Settings). For details, see Changing the Networking Configuration.
■ 关于NAT网络
拓扑图:
在NAT网络中,会使用到VMnet8虚拟交换机,Host上的VMware Network Adapter VMnet8虚拟网卡被连接到VMnet8交换机上,来与Guest进行通信,但是VMware Network Adapter VMnet8虚拟网卡仅仅是用于和VMnet8网段通信用的,它并不为VMnet8网段提供路由功能,处于虚拟NAT网络下的Guest是使用虚拟的NAT服务器来连接到Internet的。VMware功能非常强大,在NAT网络下,我们甚至可使用Port Forwarding功能,来把Host的某一个TCP或者UDP端口映射到Guest上!
如图:我的VMware Network Adapter VMnet8虚拟网卡的IP地址配置如下:
IP地址是手工指定的,但却不是由我来指定的,而是VMware在安装的时候自动随机指定的一个IP地址(注意,不要修改VMware Network Adapter VMnet8虚拟网卡所在的网络ID,这样的话会造成Host和Guest无法通信)
那么,我的NAT网络的虚拟机的IP地址也为192.168.85.0这个网段,其IP地址配置为:
可以看到,它的IP地址分是由DHCP服务器分配的的,DHCP服务器的地址为192.168.85.254,那为什么会有DHCP服务器存在呢?这是因为VMware安装之后,会有一台虚拟的DHCP服务器为虚拟机来分配IP地址,这个DHCP服务器,你可以ping通它,但是无法进行访问,因为实际上它就是一个系统服务而已,在开始——>运行中输入services.msc,就会看到这个服务:
此时可以看到,Guest的网卡和Host上的VMware Network Adapter VMnet8虚拟网卡拥有相同的网络ID,这样的话,在Guest中,ping通Host就没有问题了:
有一点需要说明的是,在NAT方式的网络中,Guest的Gateway都指向了192.168.X.2,在本例中,X=85,也就是那个虚拟的NAT服务器的地址,这个服务器是一台虚拟的NAT服务器,可以ping通它,但是却无法访问到这台虚拟机,因为这同样也是一个系统服务:
这时候,我的Guest和Host就可以实现互访了,并且如果我的Host此时已经连接到了Internet,那么我的Guest也就可以连上Internet了。那么Host上的VMware Network Adapter VMnet8虚拟网卡在这里扮演了一个什么角色呢?它仅仅是为Host和NAT虚拟网络提供了一个通信接口,所以,即便在Host中Disable掉这块虚拟网卡,Guest仍然是可以上网的,只是Host无法再访问VMnet8网段,也即是无法访问Guest而已。
VMware中对于NAT网络的定义(引用自VMware GSX Server User’s Manual):
NAT gives a virtual machine access to network resources using the host computer’s IP address.
A network address translation connection is set up automatically if you follow the Custom path in the New Virtual Machine Wizard and select Use network address translation.
If you want to connect to the Internet or other TCP/IP network using the host computer’s dial-up networking or broadband connection and you are not able to give your virtual machine an IP address on the external network, NAT is often the easiest way to give your virtual machine access to that network.
NAT also allows you to connect to a TCP/IP network using a Token Ring adapter on the host computer.
If you use NAT, your virtual machine does not have its own IP address on the external network. Instead, a separate private network is set up on the host computer. Your virtual machine gets an address on that network from the VMware virtual DHCP server. The VMware NAT device passes network data between one or more virtual machines and the external network. It identifies incoming data packets intended for each virtual machine and sends them to the correct destination.
If you select NAT, the virtual machine can use many standard TCP/IP protocols to connect to other machines on the external network. For example, you can use HTTP to browse Web sites, FTP to transfer files and Telnet to log on to other computers. In the default configuration, computers on the external network cannot initiate connections to the virtual machine. That means, for example, that the default configuration
does not let you use the virtual machine as a Web server to send Web pages to computers on the external network.
If you make some other selection in the New Virtual Machine Wizard and later decide you want to use NAT, you can make that change in the virtual machine settings editor (VM > Settings). For details, see Changing the Networking Configuration.
For a more thorough discussion of NAT, see Understanding NAT.
■ 关于Host-Only网络:
拓扑图:
在Host-Only网络中,Host-Only网络被用来设计成一个与外界隔绝的(isolated)网络,其实Host-Only网络和NAT网络非常相似,唯一不同的地方就是在Host-Only网络中,没有用到NAT服务,没有服务器为VMnet1网络做路由,它当然就没有办法访问Internet啦,可是如果此时我的Host要和Guest通信怎么办呢?当然就要用到VMware Network Adapter VMnet1这块虚拟网卡了。
如下图,这是我的Host上的VMware Network Adapter VMnet1虚拟网卡的配置,同样,VMware也为我自动随机分配好了它的IP:
那么如果我把Guest的网络设置成了Host-Only的话,把它的IP获取方式设置为DHCP,它会到虚拟的DHCP服务器上拿到IP,这个DHCP服务器仍然是一个虚拟的DHCP服务器(仅仅是一个系统服务而已),而且在下图中,可以看到,这个DHCP服务器的IP地址仍然是192.168.X.254,这里X=163,因为要和我的VMnet1的网络ID相同。所以,Guest所获得的IP和我的Host的VMware Network Adapter VMnet1虚拟网卡的IP使用同一个网络ID:
可以看到,在Host-Only网络下,Guest的Default Gateway被设置为NULL,这是由于没有默认路由器为它到外部网络提供路由的缘故,也即是上边说到的Host-Only网络没有NAT服务器!如果使用route add命令加上某个地址做为它的路由器,它仍然不能访问Internet(实际上也没有地址可加)。这样,我的Guest虽然没有办法访问Internet,但是仍然可以和我的Host进行通信,这正是因为我的Host上的VMware Network Adapter VMnet1虚拟网卡起到了作用,它负责和VMnet1网络相连,为我访问Host-Only网络下的Guest提供了通信接口。下图显示了在Host-Only网络中的Guest 与我的Host的通信情况:
至于为何要把Host-Only网络设置为没有Default Gateway的方式,这是VMware的设计使然,它就是让我们建立一个与外界隔离(isolated)的网络时而使用的。
VMware中对于Host-Only网络的定义(引用自VMware GSX Server User’s Manual):
Host-only networking creates a network that is completely contained within the host computer.
A host-only network is set up automatically if you select Use Host-Only Networking in the New Virtual Machine Wizard. On Linux hosts, this selection is available only if you enabled the host-only networking option when you installed GSX Server.
Host-only networking provides a network connection between the virtual machine and the host computer, using a virtual Ethernet adapter that is visible to the host operating system. This approach can be useful if you need to set up an isolated virtual network.
If you use host-only networking, your virtual machine and the host virtual adapter are connected to a private TCP/IP network. Addresses on this network are provided by the VMware DHCP server.
If you make some other selection in the New Virtual Machine Wizard and later decide you want to use host-only networking, you can make that change in the virtual machine settings editor (VM > Settings). For details, see Changing the Networking Configuration.
Routing and Connection Sharing
If you install the proper routing or proxy software on your host computer, you can establish a connection between the host virtual Ethernet adapter and a physical network adapter on the host computer. This allows you, for example, to connect the virtual machine to a Token Ring or other non-Ethernet network.
On a Windows 2000 or Windows Server 2003 host computer, you can use host-only networking in combination with the Internet connection sharing feature in Windows to allow a virtual machine to use the host’s dial-up networking adapter or other connection to the Internet. See your Windows documentation for details on configuring Internet connection sharing.
事实上,如果我足够BT,也可以在Host上来为VMware Network Adapter VMnet1虚拟网卡来做路由。比如,我可以用Windows 2000的RRAS来做,这样的话,处于Host-Only网络下的Guest就又可以上网了,它们只需要使用route add命令把自己的Default Gateway指向Host上的VMware Network Adapter VMnet1虚拟网卡即可,不过这样做不推荐,也没有必要:-)(有兴趣的朋友可以自己实际做一下看看)。
至此,VMware的3种网络,就应该可以理解了。可以看到,如果想要Guest上网,在3种网络模型中,最为简单的方式就是NAT,因为它不需要任何的网卡设置,IP地址也可以从虚拟的DHCP服务器来获得,要做的仅仅就是把它的网络设置为NAT方式即可。至于Bridged模式,则需要额外的IP地址,这有可能会实现不了,因为并不是每个ISP都那么大方J。如果是Host-Only,则又需要设置RRAS,没有几个人会愿意为了让虚拟机上网而换OS的,所以就用NAT最好了。在这里要强调的一点是,如果设置了Host-Only网络,非要为VMnet1做路由,一定要用RRAS,而不要用Windows XP或者2000的ICS,因为它会自动把内网的接口地址改为192.168.0.1。你在安装虚拟机的时候,VMware不会正好给你的VMware Network Adapter VMnet1虚拟网卡分配为192.168.0.1的地址吧?这样的话会造成VMware Network Adapter VMnet1虚拟网卡和VMnet1网段的网络ID不一致,自然,你的Guest就没有办法和Host通信了!
实际上经常还会遇到这样的情况:比如VMware为我分配的网络ID在将来会被我用到,或者嫌VMware为你分配的网络不好(比如它给你分了个192.168.148.0的网络ID),那么可以到这里来修改:
单击VMware的“Host”菜单,选择“Virtual Network Settings …”
选择“Host Virtual Network Mapping”中,VMnet1所在的虚拟网络,单击后边的按钮,选择“Subnet”菜单,即可以调整你的网络ID。
我在这里调整的是VMnet1,那么VMnet8当然也可以用这样的方式来调整。:-)
记住,在调整之后你的VMware Network Adapter VMnet1和VMware Network Adapter VMnet8也需要调整到相应的网络ID,不然Host和Guest如何通信呢?
初学者在使用VMware的时候,总是喜欢直接修改VMware Network Adapter for VMnet1和VMware Network Adapter for VMnet8这两块虚拟网卡的IP地址,以为把它们设置为与Host在一个网段就可以实现通信和上网,实际上在看过这篇文章之后,应该明白,修改这两块虚拟网卡,对于实现网络通信,是多么的没有帮助!
点击这里可下载本文的PDF版。

前言:本文最早发布于2005年10月,位于vmware.cn,现在原帖地址已经无法找到。

很多朋友都曾问到关于Guest和Host互联,其实这并不是一件困难的事情,只要能够理解VMware的网络模型即可,今天结合着我的虚拟机,来详细介绍一下VMware的3种网络结构。

在说到VMware的网络模型之前,先说一下VMware的几个虚拟设备:

■    VMnet0:这是VMware用于虚拟桥接网络下的虚拟交换机;

■    VMnet1:这是VMware用于虚拟Host-Only网络下的虚拟交换机;

阅读全文 »

利用 Windows 2000 的 RRAS 功能将 Host-Only 虚拟机接入 Internet

前言:本文于2005年11月发布于虚拟机之家(www.xuniji.com),原帖地址现已找不到。

以前说过,在通常情况下,Host-Only虚拟机是不可以连上外部网络的,但是这只是VMware没有为Host-Only网络提供路由而已,如果我们想让Host-Only虚拟机连到外部网络,其实也是完全可以的,不过,这需要我们在Host上来做一些设置。

本文利用一个简单的试验,来把Host-Only主机带到Internet上去,看过本文之后,相信你对VMware的网络模型会有更深的了解。

阅读全文 »

使用 VMware 搭建 ISA 2004 实验环境

前言:本文最早于2005年11月发布于 vmware.cn,现在原帖已经无法找到。

本文介绍了如何用 VMware 建立一个完整的 LAN 的教程,这里完整的 LAN 是指包括了 Server 和 Client,而与 Host 没有什么关系的 LAN。

首先规划网络,看一下这个网络的拓扑:

阅读全文 »

- 在0.439秒内共计41次数据库查询 -