从外网访问VMware虚拟机的Web服务 - graybull's Blog

从外网访问VMware虚拟机的Web服务

graybull posted @ 2013年1月04日 16:50 in VMware with tags VMware NAT port forwarding TFS Web access , 29126 阅读

    在主机上安装了VMware,VMware上安装了Linux或windows虚拟机。我想让虚拟机向外提供Web服务,于是在它上面打开了IIS(Windows)。本文讲解如何让我的主机和外网用户可以访问IIS的网站。

    我的情景是这样的:主机(windows 7)位于局域网内,要在主机上VMware安装windows 7虚拟机;虚拟机上安装Team Foundation Server2010,并向局域网其他用户提供TFS网站的访问。这里分解成几个步骤。

  • 网络拓扑
  • 原理说明
  • VMware的NAT设置
  • 端口转发(Port Forwarding)
  • 路由器和防火墙设置
  • 网络测试

网络拓扑

   该前提下的网络拓扑有3种主要类型:家庭ADSL、公司局域网和托管机房公网。我的情景是第二种。

3种常见网络模式

原理说明

    有了拓扑之后,需要了解VMware的三种网络连接模式,区分桥接(bridged)、NAT和Host-only。桥接模式,可以看成主机与虚拟机用Hub相连接。NAT是局域网的重要技术,详细解释可以看百科。NAT模式,可看成主机是关口,虚拟机在网络内部,所有与虚拟机的通信均要经过关口。Host-only模式,看成主机与虚拟机是用双绞线相连的,它们可分别处于独立的网段。

    公司局域网采用域管理,即虚拟机没有(申请)在域内,而主机在域内。所以我只能采用NAT模式,否则虚拟机没有访问网络(或被访问)的权限。

VMware的NAT设置

  • 右键点击虚拟机,选择“setting”;
  • 在左边栏的Hardware选项卡内选择Network Adapter;
  • 在右边栏选择NAT,如下图:

   

 

端口转发(Port Forwarding)

    在完成NAT设置之后,虚拟机便可以访问外部网络(局域网其他用户和Internet)了。但是,从外部网络不能访问虚拟机。这是因为NAT对外是屏蔽内部网络细节的。为了实现从外部访问虚拟机,则需要设置端口转发。

  • 查看虚拟机的IP地址

  • 在VMware的菜单项Edit下选择Vitual Network Editor;在上方选定NAT网络,在下方选择NAT(shared host's IP address with VMs),点击NAT Settings;

  • 点击Add添加端口转发;

    Host Port是主机的端口,即从外网访问主机该端口的请求,均转发至虚拟机;

    Type指定传输协议,这里添加了TCP和UDP(Http一般只使用TCP);

    Vitual Machine IP Address填写虚拟机的IP地址和端口;由于这里需提供Web服务,所以应该填写Web端口(在windows IIS的网站中设定);

路由器和防火墙设置

  • 在外部网络与主机间若有路由器,则需设置端口映射;我的情景下没有;
  • 关闭主机上的防火墙,或者设置防火墙的端口允许规则;

网络测试

  • TFS的IIS网站已经搭建好;
  • 在局域网其他用户的计算机上打开浏览器,访问http://<host's IP address>:host port;

     假设主机的IP为10.1.1.1,则在浏览器访问http://10.1.1.1:8080。正常情况下,访问请求会转发至虚拟机,即该请求实际访问的是http://192.168.75.134:8080。

  • 若正常打开Web网站,则测试通过。

 

Avatar_small
张宇恒 说:
2013年1月12日 18:49

我也是这样做的,用的是vbox。
我分享一个做法,在家里宿主win7,vbox里面ubuntu
端口转发ubuntu的transmission的端口到宿主机同端口,然后在路由器上开启虚拟服务器,把宿主机的端口再次转到公网地址端口,这样在其他地方,比如公司就能用web图形界面,控制ubuntu的transmission进行下载了。

Avatar_small
duan 说:
2014年1月12日 03:42

@张宇恒: 你好,能不能给个具体的步骤呢?谢谢了!

Avatar_small
hotmail.com login 说:
2021年1月26日 01:41

Hotmail is now one of the most used email service on the internet, create your email today with the step by step tutorial on hotmail login

Avatar_small
carpet cleaning duba 说:
2021年8月30日 00:50

Think you're hunting for a efficient office cleaning issuer in Dubai? If perhaps yes, then we you'll come to Crystal Deer are a person's ever-present significant other. We aim at use up to date cleaning machinery to shed all hard to clean stains in the office. We understand the benefits of working with a clean business. It elevates your self-belief, not post that your clean driveway improves yields. We agenda an business cleaning schedule based upon your priorities. You may inform us within your needs, and we'll take them from now there. Besides, our tailor-made offices cleaning up services allow for us in order to reach your exceptional cleaning demands.

Avatar_small
cleaning company dub 说:
2021年9月26日 19:32

What person doesn’t love property smelling amazing the whole day long, irrespective for weathers? Really, everyone should. It’s these days possible to build your place sniffing delightful all the time and regularly of any week. You bet, you look over it positively right. Just it is important to adapt some hints to hold a comfortable environment in your guests.

Avatar_small
house cleaning servi 说:
2021年11月15日 03:41

Pros assist by giving their awareness and competence to innovative franchisees. You can find ongoing support in addition, including for newsletters, security plus safety types of procedures, meetings, your toll-free aid line, online, and arena operations plus evaluations. There are actually instructional Digital video disc, a confidential website, plus advanced exercising. Maid Brigade is focused upon making convinced all franchises will be successfully plus profitably perform. The company satisfies advertising, plus sends innovative ads plus promotions so that you can each franchise.

Avatar_small
BSEM 6th Class Text 说:
2023年7月24日 23:04

Manipur Responsibilities of Preparing the Textbook, Syllabus, Study Material and Conducting Middle, Final Examination, Manipur Board 6th Class Textbook 2024 are one of the most Resourceful Tools for the Students. BSEM High School Textbooks Provide the Right and in-Depth information on a Particular topic. Also, these books act as a Framework for Facilitating Students with Effective BSEM 6th Class Textbook 2024 learning, Manipur Class Books 2024 These books aim at Analyzing the Instructional objectives of the Subject.Board 6th Class e-Books 2024 Pdf Format is Upload in Online.

Avatar_small
house cleaning servi 说:
2023年10月03日 21:23

Lube paintings add a large amount of class towards room numerous experts easily find 1000s of stores which usually sell reproductions about famous artwork. You can find the painting on your choice and get for custom remaking if necessary and therefore the manufacturer should mail the property to you. You can get yourself original artwork by smaller known artists and also paintings about photographs; the choices are different.

Avatar_small
boardmodelpaper.com 说:
2024年1月11日 06:46

Board Model Papers 2024 Download with Suggestions for 10th Class Textbooks 2024 Pdf Download and SSLC New Syllabus Sample Question Paper 2024 and different types of model papers boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course Languages & Subjects Important Question for the above link.

Avatar_small
seo service london 说:
2024年1月15日 19:47

I truly welcome the basic imagining that went into this blog. Shows signs of improvement and bette

Avatar_small
seo service UK 说:
2024年2月22日 01:47

I really like your take on the issue. I now have a clear idea on what this matter is all about


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee