IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    VMware网络连接

    羽墨发表于 2015-07-22 11:27:46
    love 0

    Bridged Networking

    VMware Bridged Networking

    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 VMware Workstation.

    If your host computer is on an Ethernet network, this is often the easiest way to give your virtual machine access to that network. Linux and Windows hosts can use bridged networking to connect to both wired and wireless networks.

    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 be running at a time. If you use one or more of the operating systems in a virtual machine, this assumption is no longer true.

    在这种模式下,VMWare虚拟出来的操作系统就像是局域网中的一台独立的主机,它可以访问网内任何一台机器。在桥接模式下,你需要手工为虚拟系统配置 IP地址、子网掩码,而且还要和宿主机器处于同一网段,这样虚拟系统才能和宿主机器进行通信。同时,由于这个虚拟系统是局域网中的一个独立的主机系统,那 么就可以手工配置它的TCP/IP配置信息,以实现通过局域网的网关或路由器访问互联网。

    使用桥接模式的虚拟系统和宿主机器的关系,就像连接在同一个Hub上的两台电脑。想让它们相互通讯,你就需要为虚拟系统配置IP地址和子网掩码,否则就无法通信。

    如果你想利用VMWare在局域网内新建一个虚拟服务器,为局域网用户提供网络服务,就应该选择桥接模式。

    这种方式最简单,直接将虚拟网卡桥接到一个物理网卡上面,和linux下一个网卡 绑定两个不同地址类似,实际上是将网卡设置为混杂模式,从而达到侦听多个IP的能力。

    在此种模式下,虚拟机内部的网卡(例如linux下的eth0)直接连到了物理网卡所在的网络上,可以想象为虚拟机和host机处于对等的地位,在网络关系上是平等的,没有谁在谁后面的问题。

    使用这种方式很简单,前提是你可以得到1个以上的地址。对于想进行种种网络实验的朋友不太适合,因为你无法对虚拟机的网络进行控制,它直接出去了。

    ** 选择桥接之后一定要重新启动主机的本地连接,否则桥接无法上网使用.这个问题可能出现在大部分人身上。**

    Network Address Translation (NAT)

    VMware NAT

    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.

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

    这种方式也可以实现Host OS与Guest OS的双向访问。但网络内其他机器不能访问Guest OS,Guest OS可通过Host OS用NAT协议访问网络内其他机器。NAT方式的IP地址配置方法是由VMware的虚拟DHCP服务器中分配一个IP ,在这个IP地址中已经设置好路由,就是指向192.168.138.1的。

    如果你想利用VMWare安装一个新的虚拟系统,在虚拟系统中不用进行任何手工配置就能直接访问互联网,建议你采用NAT模式。

    这种方式下host内部出现了一个虚拟的网卡vmnet8(默认情况下),如果你有过 做nat服务器的经验,这里的vmnet8就相当于连接到内网的网卡,而虚拟机本身则相当于运 行在内网上的机器,虚拟机内的网卡(eth0)则独立于vmnet8。

    你会发现在这种方式下,vmware自带的dhcp会默认地加载到vmnet8界面上,这样虚拟机就可以使用dhcp服务。更为重要的是,vmware自 带了nat服务,提供了从vmnet8到外网的地址转 换,所以这种情况是一个实实在在的nat服务器在运行,只不过是供虚拟机用的。

    很显然,如果你只有一个外网地址,此种方式很合适。

    Host-Only Networking

    VMware Host-Only Networking

    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 VMware Workstation.

    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 Ethernet network. Addresses on this network are provided by the VMware DHCP server.

    在某些特殊的网络调试环境中,要求将真实环境和虚拟环境隔离开,这时你就可采用host-only模式。在host-only模式中,所有的虚拟系统是可以相互通信的,但虚拟系统和真实的网络是被隔离开的。

    提示:在host-only模式下,虚拟系统和宿主机器系统是可以相互通信的,相当于这两台机器通过双绞线互连。

    在host-only模式下,虚拟系统的TCP/IP配置信息(如IP地址、网关地址、DNS服务器等),都是由VMnet1(host-only)虚拟网络的DHCP服务器来动态分配的。

    如果你想利用VMWare创建一个与网内其他机器相隔离的虚拟系统,进行某些特殊的网络调试工作,可以选择host-only模式。

    这应该是最为灵活的方式,有兴趣的话可以进行各种网络实验。和nat唯一的不同的是,此 种方式下,没有地址转换服务,因此,模认情况下,虚拟机只能到主机访问,这也是hostonly的名字的意义。

    参考

    1. VMware Workstation 5.5Configuring a Virtual Network
    2. VMWARE 虚拟机连接主机,或被其他网内的机器访问


沪ICP备19023445号-2号
友情链接