虚拟routeadd

routeadd  时间:2021-05-24  阅读:()
理解VMware的3种网络模型很多朋友都曾问到关于Guest和Host互联,其实这并不是一件困难的事情,只要能够理解VMware的网络模型即可,今天结合着我的虚拟机,来详细介绍一下VMware的3种网络结构在说到VMware的网络模型之前,先说一下VMware的几个虚拟设备:VMnet0:这是VMware用于虚拟桥接网络下的虚拟交换机;VMnet1:这是VMware用于虚拟Host-Only网络下的虚拟交换机;VMnet8:这是VMware用于虚拟NAT网络下的虚拟交换机;VMwareNetworkAdapterVMnet1:这是Host用于与Host-Only虚拟网络进行通信的虚拟网卡;VMwareNetworkAdapterVMnet8:这是Host用于与NAT虚拟网络进行通信的虚拟网卡;关于桥接网络:拓扑图:www.
s2.
cnHost的物理网卡和Guest的网卡在VMnet0交换机上通过虚拟网桥进行桥接,这也就是说,我的物理网卡和我的Guest的虚拟网卡(注:这个虚拟网卡不等于VMwareNetworkAdapterVMnet1或者VMwareNetworkAdapterVMnet8)处于同等地位,此时的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就可以互通了:www.
s2.
cn当然,Guest所配置的IP地址一定要在192.
168.
0网段没有被占用,而且我的网络管理员允许我来使用这个IP地址.
如果在192.
168.
0网段,存在DHCP服务器,那么Host和Guest都可以把IP地址获取方式设置为DHCP方式.
VMware中对于Bridged网络的定义(引用自VMwareGSXServerUser'sManual):Bridgednetworkingconnectsavirtualmachinetoanetworkusingthehostcomputer'sEthernetadapter.
BridgednetworkingissetupautomaticallyifyouselectUsebridgednetworkingintheNewVirtualMachineWizardorifyouselecttheTypicalsetuppath.
ThisselectionisavailableonaLinuxhostonlyifyouenablethebridgednetworkingoptionwhenyouinstallGSXServer.
IfyourhostcomputerisonanEthernetnetwork,bridgednetworkingisoftentheeasiestwaytogiveyourvirtualmachineaccesstothatnetwork.
OnaWindowshost,youcanusebridgednetworkingtoconnecttoeitherawiredorawirelessnetwork.
OnaLinuxhost,youcanusebridgednetworkingtoconnecttoawirednetwork.
www.
s2.
cnIfyouusebridgednetworking,yourvirtualmachineneedstohaveitsownidentityonthenetwork.
Forexample,onaTCP/IPnetwork,thevirtualmachineneedsitsownIPaddress.
YournetworkadministratorcantellyouwhetherIPaddressesareavailableforyourvirtualmachineandwhatnetworkingsettingsyoushoulduseintheguestoperatingsystem.
Generally,yourguestoperatingsystemmayacquireanIPaddressandothernetworkdetailsautomaticallyfromaDHCPserver,oryoumayneedtosettheIPaddressandotherdetailsmanuallyintheguestoperatingsystem.
Ifyouusebridgednetworking,thevirtualmachineisafullparticipantinthenetwork.
Ithasaccesstoothermachinesonthenetworkandcanbecontactedbyothermachinesonthenetworkasifitwereaphysicalcomputeronthenetwork.
Beawarethatifthehostcomputerissetuptobootmultipleoperatingsystemsandyourunoneormoreoftheminvirtualmachines,youneedtoconfigureeachoperatingsystemwithauniquenetworkaddress.
Peoplewhobootmultipleoperatingsystemsoftenassignallsystemsthesameaddress,sincetheyassumeonlyoneoperatingsystemwillrunatatime.
Ifyouuseoneormoreoftheoperatingsystemsinavirtualmachine,thisassumptionisnolongertrue.
IfyoumakesomeotherselectionintheNewVirtualMachineWizardandlaterdecideyouwanttousebridgednetworking,youcanmakethatchangeinthevirtualmachinesettingseditor(VM>Settings).
Fordetails,seeChangingtheNetworkingConfiguration.
关于NAT网络拓扑图:在NAT网络中,会使用到VMnet8虚拟交换机,Host上的VMwareNetworkAdapterVMnet8虚拟网卡被连接到VMnet8交换机上,来与Guest进行通信,但是VMwareNetworkAdapterVMnet8虚拟网卡仅仅是用于和VMnet8网段通信用的,它并不为VMnet8网段提供路由功能,处于虚拟NAT网络下的Guest是使用虚拟的NAT服务器来连接到Internet的.
VMware功能非常强大,在NAT网络下,我们甚至可使用PortForwarding功能,来把Host的某一个TCP或者UDP端口映射到Guest上!
如图:我的VMwareNetworkAdapterVMnet8虚拟网卡的IP地址配置如下:IP地址是手工指定的,但却不是由我来指定的,而是VMware在安装的时候自动随机指定的一个IP地址(注意,不要修改VMwareNetworkAdapterVMnet8虚拟网卡所在的网络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上的VMwareNetworkAdapterVMnet8虚拟网卡拥有相同的网络ID,这样的话,在Guest中,ping通Host就没有问题了:有一点需要说明的是,在NAT方式的网络中,Guest的Gateway都指向了192.
168.
X.
2,在本例中,X=85,也就是那个虚拟的NAT服务器的地址,这个服务器是一台虚拟的NAT服务器,可以ping通它,但是却无法访问到这台虚拟机,因为这同样也是一个系统服务:这时候,我的Guest和Host就可以实现互访了,并且如果我的Host此时已经连接到了Internet,那么我的Guest也就可以连上Internet了.
那么Host上的VMwareNetworkAdapterVMnet8虚拟网卡在这里扮演了一个什么角色呢它仅仅是为Host和NAT虚拟网络提供了一个通信接口,所以,即便在Host中Disable掉这块虚拟网卡,Guest仍然是可以上网的,只是Host无法再访问VMnet8网段,也即是无法访问Guest而已.
VMware中对于NAT网络的定义(引用自VMwareGSXServerUser'sManual):NATgivesavirtualmachineaccesstonetworkresourcesusingthehostcomputer'sIPaddress.
AnetworkaddresstranslationconnectionissetupautomaticallyifyoufollowtheCustompathintheNewVirtualMachineWizardandselectUsenetworkaddresstranslation.
IfyouwanttoconnecttotheInternetorotherTCP/IPnetworkusingthehostcomputer'sdial-upnetworkingorbroadbandconnectionandyouarenotabletogiveyourvirtualmachineanIPaddressontheexternalnetwork,NATisoftentheeasiestwaytogiveyourvirtualmachineaccesstothatnetwork.
NATalsoallowsyoutoconnecttoaTCP/IPnetworkusingaTokenRingadapteronthehostcomputer.
IfyouuseNAT,yourvirtualmachinedoesnothaveitsownIPaddressontheexternalnetwork.
Instead,aseparateprivatenetworkissetuponthehostcomputer.
YourvirtualmachinegetsanaddressonthatnetworkfromtheVMwarevirtualDHCPserver.
TheVMwareNATdevicepassesnetworkdatabetweenoneormorevirtualmachinesandtheexternalnetwork.
Itidentifiesincomingdatapacketsintendedforeachvirtualmachineandsendsthemtothecorrectdestination.
IfyouselectNAT,thevirtualmachinecanusemanystandardTCP/IPprotocolstoconnecttoothermachinesontheexternalnetwork.
Forexample,youcanuseHTTPtobrowseWebsites,FTPtotransferfilesandTelnettologontoothercomputers.
Inthedefaultconfiguration,computersontheexternalnetworkcannotinitiateconnectionstothevirtualmachine.
Thatmeans,forexample,thatthedefaultconfigurationdoesnotletyouusethevirtualmachineasaWebservertosendWebpagestocomputersontheexternalnetwork.
IfyoumakesomeotherselectionintheNewVirtualMachineWizardandlaterdecideyouwanttouseNAT,youcanmakethatchangeinthevirtualmachinesettingseditor(VM>Settings).
Fordetails,seeChangingtheNetworkingConfiguration.
ForamorethoroughdiscussionofNAT,seeUnderstandingNAT.
关于Host-Only网络:拓扑图:在Host-Only网络中,Host-Only网络被用来设计成一个与外界隔绝的(isolated)网络,其实Host-Only网络和NAT网络非常相似,唯一不同的地方就是在Host-Only网络中,没有用到NAT服务,没有服务器为VMnet1网络做路由,它当然就没有办法访问Internet啦,可是如果此时我的Host要和Guest通信怎么办呢当然就要用到VMwareNetworkAdapterVMnet1这块虚拟网卡了.
如下图,这是我的Host上的VMwareNetworkAdapterVMnet1虚拟网卡的配置,同样,VMware也为我自动随机分配好了它的IP:那么如果我把Guest的网络设置成了Host-Only的话,把它的IP获取方式设置为DHCP,它会到虚拟的DHCP服务器上拿到IP,这个DHCP服务器仍然是一个虚拟的DHCP服务器(仅仅是一个系统服务而已),而且在下图中,可以看到,这个DHCP服务器的IP地址仍然是192.
168.
X.
254,这里X=163,因为要和我的VMnet1的网络ID相同.
所以,Guest所获得的IP和我的Host的VMwareNetworkAdapterVMnet1虚拟网卡的IP使用同一个网络ID:可以看到,在Host-Only网络下,Guest的DefaultGateway被设置为NULL,这是由于没有默认路由器为它到外部网络提供路由的缘故,也即是上边说到的Host-Only网络没有NAT服务器!
如果使用routeadd命令加上某个地址做为它的路由器,它仍然不能访问Internet(实际上也没有地址可加).
这样,我的Guest虽然没有办法访问Internet,但是仍然可以和我的Host进行通信,这正是因为我的Host上的VMwareNetworkAdapterVMnet1虚拟网卡起到了作用,它负责和VMnet1网络相连,为我访问Host-Only网络下的Guest提供了通信接口.
下图显示了在Host-Only网络中的Guest与我的Host的通信情况:至于为何要把Host-Only网络设置为没有DefaultGateway的方式,这是VMware的设计使然,它就是让我们建立一个与外界隔离(isolated)的网络时而使用的.
www.
s2.
cnVMware中对于Host-Only网络的定义(引用自VMwareGSXServerUser'sManual):Host-onlynetworkingcreatesanetworkthatiscompletelycontainedwithinthehostcomputer.
Ahost-onlynetworkissetupautomaticallyifyouselectUseHost-OnlyNetworkingintheNewVirtualMachineWizard.
OnLinuxhosts,thisselectionisavailableonlyifyouenabledthehost-onlynetworkingoptionwhenyouinstalledGSXServer.
Host-onlynetworkingprovidesanetworkconnectionbetweenthevirtualmachineandthehostcomputer,usingavirtualEthernetadapterthatisvisibletothehostoperatingsystem.
Thisapproachcanbeusefulifyouneedtosetupanisolatedvirtualnetwork.
Ifyouusehost-onlynetworking,yourvirtualmachineandthehostvirtualadapterareconnectedtoaprivateTCP/IPnetwork.
AddressesonthisnetworkareprovidedbytheVMwareDHCPserver.
IfyoumakesomeotherselectionintheNewVirtualMachineWizardandlaterdecideyouwanttousehost-onlynetworking,youcanmakethatchangeinthevirtualmachinesettingseditor(VM>Settings).
Fordetails,seeChangingtheNetworkingConfiguration.
RoutingandConnectionSharingIfyouinstalltheproperroutingorproxysoftwareonyourhostcomputer,youcanestablishaconnectionbetweenthehostvirtualEthernetadapterandaphysicalnetworkadapteronthehostcomputer.
Thisallowsyou,forexample,toconnectthevirtualmachinetoaTokenRingorothernon-Ethernetnetwork.
OnaWindows2000orWindowsServer2003hostcomputer,youcanusehost-onlynetworkingincombinationwiththeInternetconnectionsharingfeatureinWindowstoallowavirtualmachinetousethehost'sdial-upnetworkingadapterorotherconnectiontotheInternet.
SeeyourWindowsdocumentationfordetailsonconfiguringInternetconnectionsharing.
事实上,如果我足够BT,也可以在Host上来为VMwareNetworkAdapterVMnet1虚拟网卡来做路由.
比如,我可以用Windows2000的RRAS来做,这样的话,处于Host-Only网络下的Guest就又可以上网了,它们只需要使用routeadd命令把自己的DefaultGateway指向Host上的VMwareNetworkAdapterVMnet1虚拟网卡即可,不过这样做不推荐,也没有必要(有兴趣的朋友可以自己实际做一下看看).
至此,VMware的3种网络,就应该可以理解了.
可以看到,如果想要Guest上网,在3种网络模型中,最为简单的方式就是NAT,因为它不需要任何的网卡设置,IP地址也可以从虚拟的DHCP服务器来获得,要做的仅仅就是把它的网络设置为NAT方式即可.
至于Bridged模式,则需要额外的IP地址,这有可能会实现不了,因为并不是每个ISP都那么大方.
如果是Host-Only,则又需要设置RRAS,没有几个人会愿意为了让虚拟机上网而换OS的,所以就用NAT最好了.
在这里要强调的一点是,如果设置了Host-Only网络,非要为VMnet1做路由,一定要用RRAS,而不要用WindowsXP或者2000的ICS,因为它会自动把内网的接口地址改为192.
168.
0.
1.
你在安装虚拟机的时候,VMware不会正好给你的VMwareNetworkAdapterVMnet1虚拟网卡分配为192.
168.
0.
1的地址吧这样的话会造成VMwareNetworkAdapterVMnet1虚拟网卡和VMnet1网段的网络ID不一致,自然,你的Guest就没有办法和Host通信了!
实际上经常还会遇到这样的情况:比如VMware为我分配的网络ID在将来会被我用到,或者嫌VMware为你分配的网络不好(比如它给你分了个192.
168.
148.
0的网络ID),那么可以到这里来修改:单击VMware的"Host"菜单,选择"VirtualNetworkSettings.
.
.
"www.
s2.
cn选择"HostVirtualNetworkMapping"中,VMnet1所在的虚拟网络,单击后边的按钮,选择"Subnet"菜单,即可以调整你的网络ID.
我在这里调整的是VMnet1,那么VMnet8当然也可以用这样的方式来调整.
记住,在调整之后你的VMwareNetworkAdapterVMnet1和VMwareNetworkAdapterVMnet8也需要调整到相应的网络ID,不然Host和Guest如何通信呢初学者在使用VMware的时候,总是喜欢直接修改VMwareNetworkAdapterVMnet1和VMwareNetworkAdapterVMnet8这两块虚拟网卡的IP地址,以为把它们设置为与Host在一个网段就可以实现通信和上网,实际上在看过这篇文章之后,应该明白,修改这两块虚拟网卡,对于实现网络通信,是多么的没有帮助!

Ceranetworks顶级合作伙伴 香港E3 16G 299元 香港E5 32G 650元 美国E3 16G 650元

提速啦(www.tisula.com)是赣州王成璟网络科技有限公司旗下云服务器品牌,目前拥有在籍员工40人左右,社保在籍员工30人+,是正规的国内拥有IDC ICP ISP CDN 云牌照资质商家,2018-2021年连续4年获得CTG机房顶级金牌代理商荣誉 2021年赣州市于都县创业大赛三等奖,2020年于都电子商务示范企业,2021年于都县电子商务融合推广大使。资源优势介绍:Ceranetwo...

ZJI:台湾CN2/香港高主频服务器7折每月595元起,其他全场8折

ZJI原名维翔主机,是原来Wordpress圈知名主机商家,成立于2011年,2018年9月更名为ZJI,提供香港、日本、美国独立服务器(自营/数据中心直营)租用及VDS、虚拟主机空间、域名注册业务。ZJI今年全新上架了台湾CN2线路服务器,本月针对香港高主频服务器和台湾CN2服务器提供7折优惠码,其他机房及产品提供8折优惠码,优惠后台湾CN2线路E5服务器月付595元起。台湾一型CPU:Inte...

SunthyCloud阿里云国际版分销商注册教程,即可PayPal信用卡分销商服务器

阿里云国际版注册认证教程-免绑卡-免实名买服务器安全、便宜、可靠、良心,支持人民币充值,提供代理折扣简介SunthyCloud成立于2015年,是阿里云国际版正规战略级渠道商,也是阿里云国际版最大的分销商,专业为全球企业客户提供阿里云国际版开户注册、认证、充值等服务,通过SunthyCloud开通阿里云国际版只需要一个邮箱,不需要PayPal信用卡就可以帮你开通、充值、新购、续费阿里云国际版,服务...

routeadd为你推荐
计算机xp如时间选项无法打开请更改dominavimasios7photoshop技术什么是ps技术重庆电信宽带管家如何才能以正确的流程在重庆电信安装上宽带迅雷快鸟迅雷快鸟支持移动宽带提速吗win7关闭135端口win7系统 怎么关闭135 445 端口 修改注册表 创建IP安全策略 也试过 就是关不了 还望高手指教fastreport2.5护套线BV2.5中的2.5是指什么尺寸,单位是什么,BV又是什么意思?morphvoxpro怎么用怎么使用morphvox proios6.1.3越狱苹果手机版本6.1.3 什么时候可以越狱 要等多久?
万网域名 老鹰主机 Dedicated 香港托管 godaddy eq2 e蜗 169邮箱 速度云 共享主机 hktv 美国盐湖城 ssl加速 存储服务器 新疆服务器 香港ip 聚惠网 ncp是什么 美国达拉斯 域名商城 更多