1. 前言
![](http://static.javashuo.com/static/loading.gif)
安裝好虛擬機之後,在網絡鏈接裏面能夠看到多了兩塊網卡,其中VMnet1是虛擬機Host-only模式的網絡接口,VMnet8是NAT模式的網絡接口,加上另外一種橋接模式構成了虛擬機中的三種網絡模式。
2. 橋接模式
1) 介紹
Ø 基本配置
橋接模式下,VMware虛擬出來的操做系統就像是局域網中的一臺獨立的主機,他能夠訪問網內任何一臺機器。須要手工爲虛擬系統配置IP地址、子網掩碼,並且還要跟主機處於同一網段,這樣虛擬系統才能和主機進行通訊。
Ø 可實現的通訊方式
橋接方式中的主機與虛擬機可當作是同一局域網的兩臺機器,可實現虛擬機到主機、虛擬機到互聯網的通訊。
Ø 適合的環境
橋接須要一個不一樣於原主機上的另一個獨立的IP地址,這對於IP和MAC綁定等特殊狀況比較難辦到。而且主機拔掉網線後,虛擬機沒法與主機經過網絡的方式進行通信。
Ø 優點
橋接模式下利用VMware在局域網內新建一個虛擬服務器,可爲局域網用戶提供網絡服務。
2) 虛擬機到主機的通訊
Ø 設置網絡鏈接模式
![](http://static.javashuo.com/static/loading.gif)
雙擊Network Adapter
![](http://static.javashuo.com/static/loading.gif)
在Network connection中選擇Bridged(橋接),單擊OK,啓動系統
Ø 查看主機IP
![](http://static.javashuo.com/static/loading.gif)
IP地址爲192.168.1.2,子網掩碼爲255.255.255.0,網關爲192.168.1.1
Ø 設置虛擬機系統IP
![](http://static.javashuo.com/static/loading.gif)
打開圖形化設置
![](http://static.javashuo.com/static/loading.gif)
雙擊eth0網卡
![](http://static.javashuo.com/static/loading.gif)
將IP地址設置爲192.168.1.3,子網掩碼255.255.255.0,網關192.168.1.1,單擊OK
![](http://static.javashuo.com/static/loading.gif)
提示是否保存已改變的設置,單擊Yes
![](http://static.javashuo.com/static/loading.gif)
提示設置的新內容已保存,可能須要重啓網絡服務或重啓計算機,單擊OK
Ø 重啓服務
![](http://static.javashuo.com/static/loading.gif)
ifconfig查看網卡信息,eth0的地址已經更改
Ø 測試
![](http://static.javashuo.com/static/loading.gif)
虛擬機可以ping通主機
![](http://static.javashuo.com/static/loading.gif)
主機可以ping通虛擬機
3) 設置多網卡橋接
Ø 編輯虛擬機網絡
![](http://static.javashuo.com/static/loading.gif)
打開網絡編輯器,開始
à全部程序
àVMware
àVritual Network Editor
![](http://static.javashuo.com/static/loading.gif)
選擇VMnet2,在下面的VMnet Information中選擇Bridged,而且指明所橋接的網卡(Bridged to)
Ø 選擇其餘橋接網卡
![](http://static.javashuo.com/static/loading.gif)
在其餘虛擬系統中,雙擊Network Adapter打開虛擬機的網絡配置
![](http://static.javashuo.com/static/loading.gif)
選擇Custom,在下拉框中選中剛剛設置的VMnet2(Bridged)
4) 虛擬機到互聯網的通訊
Ø 設置自動獲取IP
![](http://static.javashuo.com/static/loading.gif)
因爲在橋接模式下主機與虛擬機可當作是同一局域網的兩臺機,而我主機所處在自動獲取IP地址的網絡中,因此在虛擬機中也讓IP地址、子網掩碼等信息自動獲取
Ø 查看網卡信息
![](http://static.javashuo.com/static/loading.gif)
Ø 測試
![](http://static.javashuo.com/static/loading.gif)
因爲使用的是英文操做系統,沒有安裝中文包,因此顯示的是亂碼
3. 網絡地址轉換模式
1) 介紹
Ø 基本配置
網絡地址轉換模式,就是讓虛擬系統藉助NAT(網絡地址轉換)功能,經過主機所在的網絡來訪問互聯網。NAT模式下的虛擬系統的TCP/IP配置信息是由VMnet8(NAT)虛擬網絡的DHCP服務器提供的,沒法進行手工修改。
Ø 可實現的通訊方式
網絡地址轉換模式下可實現虛擬機與主機通訊,虛擬機與互聯網通訊
Ø 適合的環境
在虛擬機與互聯網通訊時,不能夠把虛擬機做爲服務器讓互聯網訪問。而且虛擬系統沒法和本局域網中的其餘真實主機進行通信。
Ø 優點
網絡地址轉換模式下利用VMware安裝一個新的虛擬系統,在主機能訪問互聯網條件下,在虛擬系統中不用進行任何手工配置就能直接訪問互聯網。
2) 虛擬機與主機、互聯網通訊
Ø 設置網絡鏈接模式
![](http://static.javashuo.com/static/loading.gif)
中止虛擬機運行後,在虛擬機網絡設置中,選擇NAT模式
Ø 設置IP
![](http://static.javashuo.com/static/loading.gif)
開啓虛擬機後,設置IP爲自動獲取
Ø 重啓服務
![](http://static.javashuo.com/static/loading.gif)
Ø 查看網絡信息
![](http://static.javashuo.com/static/loading.gif)
查看網絡信息看到獲取到一個192.168.129.130的IP地址
Ø 測試聯網
![](http://static.javashuo.com/static/loading.gif)
Ø 測試與主機通訊
![](http://static.javashuo.com/static/loading.gif)
虛擬機可以ping通主機
![](http://static.javashuo.com/static/loading.gif)
主機可以ping通虛擬機
4. 主機模式
1) 介紹
Ø 基本配置
虛擬系統的TCP/IP配置信息IP地址、網關地址、DNS服務器等,都是由VMnet1(Host-only)虛擬網絡的DHCP服務器來動態分配的。
Ø 可實現的通訊方式
主機模式中,全部的虛擬系統是能夠相互通訊的,但虛擬系統和主機上的系統是被隔離開的。能夠利用Windows XP裏面自帶的Internet鏈接共享,其實是一個簡單的路由NAT,來讓虛擬機經過主機真實的網卡進行與主機通訊。也就是說能夠實現虛擬系統與虛擬系統通訊以及虛擬系統與主機通訊。
Ø 適合的環境
在某些特殊的網絡調試環境中,要求將真實環境和虛擬環境隔離開,就可採用Host-only模式。
Ø 優點
主機模式下利用VMware建立一個與網內其餘機器相隔離的虛擬系統,能夠選擇Host-only模式
2) 虛擬系統與虛擬系統通訊
Ø 設置網絡鏈接模式
![](http://static.javashuo.com/static/loading.gif)
中止虛擬機運行後,在虛擬機網絡設置中,設置Windows2003系統的網絡模式爲Host-only模式
![](http://static.javashuo.com/static/loading.gif)
中止虛擬機運行後,在虛擬機網絡設置中,設置Linux5.4系統的網絡模式爲Host-only模式
Ø 設置IP
![](http://static.javashuo.com/static/loading.gif)
將Windows2003中的網絡信息設置爲自動獲取,使用命令ipconfig查看網絡信息能夠看到自動獲取了一個192.168.20.128的IP
![](http://static.javashuo.com/static/loading.gif)
將Linux5.4中的網絡信息設置爲自動獲取,使用命令ifconfig查看網絡信息能夠看到自動獲取了一個192.168.20.129的IP
Ø 測試
![](http://static.javashuo.com/static/loading.gif)
虛擬Linux5.4系統可以ping通虛擬Windows2003系統
![](http://static.javashuo.com/static/loading.gif)
虛擬Windows2003系統可以ping通虛擬Linux5.4系統
虛擬Linux5.4不可以Ping通主機,提示網絡不可達
![](http://static.javashuo.com/static/loading.gif)
虛擬Windows2003不可以Ping通主機,提示目標主機不可達
3) 虛擬系統與主機通訊
Ø 共享主機Internet鏈接方式
![](http://static.javashuo.com/static/loading.gif)
在網絡圖標上,單擊右鍵選擇屬性
![](http://static.javashuo.com/static/loading.gif)
在高級標籤中的Internet鏈接共享中勾選容許其餘網絡用戶經過此計算機的Internet鏈接來鏈接,而且在下面的下拉框中選擇VMware Network Adapter VMnet1,若是容許其餘網絡用戶控制或禁用共享的Internet鏈接,則勾選對應的複選框,設置好後單擊肯定
![](http://static.javashuo.com/static/loading.gif)
單擊肯定後會提示會將VMnet1的地址改成192.168.0.1,單擊肯定便可
Ø 設置IP
![](http://static.javashuo.com/static/loading.gif)
將Linux5.4的虛擬系統的IP設置爲192.168.0.0/24的網段IP,網管設置爲192.168.0.1
Ø 重啓服務
![](http://static.javashuo.com/static/loading.gif)
Ø 測試
![](http://static.javashuo.com/static/loading.gif)
虛擬機可以ping通主機