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