5、網絡配置
5.1、場景
yper-V2012的安裝,由於是CORE模式,所以沒有配置虛擬網絡。通過控制檯或遠程桌面,在HOST上查看配置網絡配置。
D:\>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . :CT-HYNODE3
Primary Dns Suffix . . . . . . . :yunhedata.com
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : yunhedata.com
Ethernet adapter Ethernet0: 默認設置
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . :Intel(R) 82574L Gigabit Network Connection
Physical Address. . . . . . . . . :00-50-56-B2-13-7F
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . :fe80::9578:42bd:4aad:11ae%13(Preferred)
IPv4 Address. . . . . . . . . . . :192.168.1.83(Preferred)
Subnet Mask . . . . . . . . . . . :255.255.255.0
Default Gateway . . . . . . . . . :192.168.1.1
DHCPv6 IAID . . . . . . . . . . . :318787670
DHCPv6 Client DUID. . . . . . . . :00-01-00-01-1B-87-4B-D0-00-50-56-B2-13-7F
DNS Servers . . . . . . . . . . . :192.168.1.11
192.168.1.12
NetBIOS over Tcpip. . . . . . . . : Enabled
Tunnel adapterisatap.{F0257AF5-B14C-4A34-B3CD-CABD0AE12796}:
Media State . . . . . . . . . . . : Mediadisconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . :Microsoft ISATAP Adapter
Physical Address. . . . . . . . . :00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
這時,在其上創建虛擬機時沒有網絡連接的,通過GUEST操作系統的命令或工具可以觀察到這種情況。
5.2、創建虛擬交換機
在HOST管理中,選擇虛擬交換機管理器。
當前沒有虛擬交換機,點擊創建虛擬交換機按鈕。
指定一個清晰、有意義的新虛擬機的交換機的名稱。
這個時候,我們可以在Host上查看配置網絡配置,觀察其變化。
D:\>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . :CT-HYNODE3
Primary Dns Suffix . . . . . . . :yunhedata.com
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . :yunhedata.com
Ethernet adapter vEthernet (Office):
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Hyper-VVirtual Ethernet Adapter #2 變成虛擬網卡
Physical Address. . . . . . . . . :00-50-56-B2-13-7F
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . :fe80::605a:6bb7:cab7:9bd5%23(Preferred)
IPv4 Address. . . . . . . . . . . :192.168.1.83(Preferred)
Subnet Mask . . . . . . . . . . . :255.255.255.0
Default Gateway . . . . . . . . . :192.168.1.1
DHCPv6 IAID . . . . . . . . . . . :385896534
DHCPv6 Client DUID. . . . . . . . :00-01-00-01-1B-87-4B-D0-00-50-56-B2-13-7F
DNS Servers . . . . . . . . . . . :192.168.1.11
192.168.1.12
NetBIOS over Tcpip. . . . . . . . : Enabled
Tunnel adapterisatap.{9E05183E-BE65-4456-83FC-01AECE398990}:
Media State . . . . . . . . . . . : Mediadisconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . :Microsoft ISATAP Adapter
Physical Address. . . . . . . . . :00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
D:\>
5.3、修改虛擬機
創建完新的虛擬交換機後,就會爲指定虛擬機連接到虛擬交換機。
5.4、實驗-NAT
爲了深入理解Hyper-V的網絡,我們做一個綜合實驗。
5.4.1、拓撲
Office網絡:172.16.1.0/24
LAB網絡:10.0.0.0/8
SRV1在LAB網絡的IP地址爲:10.0.0.254,啓用NAT功能
SRV2的IP地址爲:10.0.0.10/8,網關爲10.0.0.254
5.4.2、在Host上添加新的虛擬機交換機LAB
通過Console或RDP連接到HOST,查看網絡配置,我們會發現多了一個網絡連接。
D:\>ipconfig/all | more
Windows IP Configuration
Host Name . . . . . . . . . . . . :CT-HYNODE3
Primary Dns Suffix . . . . . . . :yunhedata.com
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . :yunhedata.com
Ethernet adapter vEthernet (Lab):
Connection-specific DNS Suffix . :
Description . . .. : Hyper-V VirtualEthernet Adapter #3
Physical Address. . . . . . . . . :00-15-5D-01-53-04
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . :
fe80::2037:e07e:2902:943e%35(Preferred)
Autoconfiguration IPv4 Address. . :169.254.148.62(Preferred)
Subnet Mask . . . . . . . . . . . :255.255.0.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 587208029
DHCPv6 Client DUID. . :00-01-00-01-1B-87-4B-D0-00-50-56-B2-13-7F
DNS Servers . . . . . . . . . . . :fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
Ethernet adapter vEthernet (Office):
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Hyper-VVirtual Ethernet Adapter
#2
Physical Address. . . . . . . . . :00-50-56-B2-13-7F
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . :
fe80::605a:6bb7:cab7:9bd5%23(Preferred)
IPv4 Address. . . . . . . . . . . :192.168.1.83(Preferred)
Subnet Mask . . . . . . . . . . . :255.255.255.0
Default Gateway . . . . . . . . . :192.168.1.1
DHCPv6 IAID . . . . . . . . . . . : 385896534
DHCPv6 Client DUID.. . :00-01-00-01-1B-87-4B-D0-00-50-56-B2-13-7F
DNS Servers . . . . . . . . . . . :192.168.1.11
192.168.1.12
NetBIOS over Tcpip. . . . . . . . : Enabled
Tunnel adapterisatap.{9E05183E-BE65-4456-83FC-01AECE398990}:
Media State . . . . . . . . . . . : Mediadisconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . :Microsoft ISATAP Adapter
Physical Address. . . . . . . . . :00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Tunnel adapterisatap.{5842CD52-A667-470D-A9FB-705AAB210B62}:
Media State . . . . . . . . . . . : Mediadisconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . :Microsoft ISATAP Adapter #2
Physical Address. . . . . . . . . :00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
5.5配置SRV1虛擬機
5.5.1、在虛擬機SRV1上添加新的網卡
只在關閉虛擬機的情況下,才能添加新網卡。
5.5.2、啓動SRV1上NAT功能
修改網絡連接的名稱,以方便管理。
複查IP地址及網絡連接名稱是否正確
5.5.3、配置及啓動路由和遠程訪問。
5.5.4、啓動SRV2上網絡
在SRV2配置上修改網絡適配器卡連接虛擬交換機爲LAB
修改IP地址,缺省網管指向SRV1的LAB接口地址10.0.0.254
6、遠程管理
在域環境中,遠程管理Hyper-V比較方便,但有時候,我們需要在工作組中計算機來進行遠程管理。
工作組環境又分爲桌面PC和服務器兩種連接方式。
6.1、工作組環境下的Hyper-V管理
必要條件
工作環境中進行Hyper-V遠程管理,必須在遠程管理主機上進行一下操作:
1、保證主機名解析,如:添加C:\Windows\System32\drivers\etc\hosts記錄
2、設置COM安全,允許Anonymouslogon遠程訪問權限
3、設置Hyper-V服務器爲信任的主機
4、如果與Hyper-V服務器用戶賬戶不同,需要添加賬戶憑據
5、添加適當的管理工具
本實驗的測試環境:
客戶機是工作組環境,而目標服務器是域環境中成員服務器
6.1.1、主機名解析
以管理員的身份運行記事本,或者其它你愛好使用的文本編輯器。
6.1.2、設置COM安全,允許Anonymous Logon遠程訪問權限
在運行中輸入dcomcnfg
6.1.3、設置Hyper-V服務器爲信任的主機
以管理員的身份去運行PowerShell
Set-Itemwsman:\localhost\Client\TrustedHosts CT-HYNODE1 –
Concatenate
PS C:\Windows\system32> Set-Itemwsman:\localhost\Client\TrustedHosts CT-HYNODE1
-Concatenate
Start WinRM Service
WinRM service is not started currently.Running this command will start the WinRM service.
Do you want to continue?
[Y] Yes [N] No [S] Suspend [?] Help(default is "Y"): Y
WinRM Security Configuration.
This command modifies the TrustedHosts listfor the WinRM client. The computers in the
TrustedHosts list might not be
authenticated. The client might sendcredential information to these computers. Are you sure
that you want to modify
this list?
[Y] Yes [N] No [S] Suspend [?] Help(default is "Y"): Y
PS C:\Windows\system32> Set-Itemwsman:\localhost\Client\TrustedHosts CT-HYNODE2
-Concatenate
WinRM Security Configuration.
This command modifies the TrustedHosts listfor the WinRM client. The computers in the
TrustedHosts list might not be
authenticated. The client might sendcredential information to these computers. Are you sure
that you want to modify
this list?
[Y] Yes [N] No [S] Suspend [?] Help(default is "Y"): Y
PS C:\Windows\system32> Set-Item wsman:\localhost\Client\TrustedHostsCT-HYNODE3
-Concatenate -Force
PS C:\Windows\system32>
6.1.4、在遠程管理主機上添加賬戶憑據
通常情況下,在Hyper-V服務器與遠程管理主機上創建用戶名及明碼相同的賬戶比較方便,如果條件不允許,那麼需要在遠程管理主機上指定連接到Hyper-V服務器的賬戶憑據。
我們需要使用Cmdkey來創建、列出和刪除存儲用戶名和密碼或憑據。
cmdkey /add:<ServerName>/user:<UserName> /pass:<password>
示例如下:
cmdkey /add: CT-HYNODE1 /user:administrator/pass:P@ssw0rd
cmdkey /add: CT-HYNODE2 /user:administrator/pass:P@ssw0rd
cmdkey /add: CT-HYNODE3 /user:administrator/pass:P@ssw0rd
6.1.5、添加適當的管理工具
windows 2012上添加
windows 8.1上添加
6.2、遠程管理
6.3、域環境的Hyper-V管理
相對於工作組,在域環境下管理很簡單,只需要使用Hyper-V管理器直接進行遠程連接即可。
6.4、工作組環境的服務器管理
Windows 2012的服務器功能很強大,可以對服務器遠程進行管理。
在工作組環境下,一定要將被管理的遠程服務器添加爲信任的主機,否則,就會出現以下錯誤。
詳細操作,請參見前面《設置Hyper-V服務器爲信任的主機》小節。
Windows PowerShell
版權所有 (C) 2013 MicrosoftCorporation。保留所有權利。
PS C:\Users\Administrator> Set-Itemwsman:\localhost\Client\TrustedHosts CT-HYNODE1
-Concatenate -Force
PS C:\Users\Administrator> Set-Itemwsman:\localhost\Client\TrustedHosts CT-HYNODE2
-Concatenate -Force
PS C:\Users\Administrator> Set-Itemwsman:\localhost\Client\TrustedHosts CT-HYNODE3
-Concatenate -Force
PS C:\Users\Administrator>
但是,當進行磁盤管理時,卻出現RPC服務不可用錯誤。
The RPC server is unavailable
這與管理機的防火牆規則有關。
6.5、域環境的服務器管理
相對於工作組環境,在域環境中
6.6、參考
將服務器添加到服務器管理器
http://technet.microsoft.com/library/hh831453
ManageHyper-V Server Remotely
http://technet.microsoft.com/en-us/library/jj647785.aspx
WindowsServer 2012 - Server ManagerTroubleshooting Guide, Part II Troubleshoot
ManageabilityStatus Errors in Server Manager
RemoteServer Administration Tools for Windows 8
http://www.microsoft.com/en-us/download/details.aspx?id=28972
RemoteServer Administration Tools for Windows 8.1
http://www.microsoft.com/en-us/download/details.aspx?id=3929