标题: Vmware中的虚拟网络 [打印本页] 作者: linda 时间: 2015-11-29 00:41 标题: Vmware中的虚拟网络
作者:张华 发表于:2013-03-27
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
( http://blog.csdn.net/quqi99 )
导读:hyper-v需要安装上支持虚拟化的物理机上,但是没有物理机啊。怎么办呢?就是通过Vmware来虚拟,更难能可贵的是,虚出一虚机也能支持硬件虚拟化,这里可以在Vmware的虚机里来安装hyper-v。更一方面,想做vlan方面的实验,得把vmware的虚拟网络的原理搞明白。
1 安装vmware workstation 9.0.2 for linux, 可参考:http://www.linuxidc.com/Linux/2012-10/73141.htm
2 用vmware创建一个虚机用于安装windows 2012 server, 给了16G的硬盘空间, 并在此启用hyper-v角色。网络为vmware的NAT模式。
2.1 因为是在虚拟机上又虚拟化,所以确保vmware虚拟机setting选项中的processors启用了Virtualize intel VT-x/EPT or ADM-V/RVT和Virtualize cpu performance counters这两个选项, 参见:http://hi.baidu.com/cjp19882009/item/a72f743636b42880f4e4ad6e 或http://communities.vmware.com/docs/DOC-8970/
2.2 再修改配置文件/run/media/hua/E/vmwareimage/WindowsServer2012/WindowsServer2012.vmx,添加下面两行。
hypervisor.cpuid.v0 = "FALSE"
mce.enable = "TRUE"
2.3 最后,关闭windows server 2012的防火墙。
2.4 在hyper-v管理器中创建一网桥br-int, 它报错:The virtual machine's operating system has attempted to enable promiscuous mode on adapter Ethernet0. This is not allowed for security reasons. Please go to the Web page "http://vmware.com/info?id=161" for help enabling promiscuous mode in the virtual machine.
所以需要人工将网卡vmnet8(NAT模式使用的是vmnet8)设置为混杂模式,因为vmnet8网卡是由root用户安装的,而vmware workstation是通过普通用户hua启动的。对于不使用udev而直接用/dev的linux的改动如下: http://blog.martinshouse.com/2011/05/vmware-on-linux-promiscuous-mode.html
[hua@zhanghua WindowsServer2012]$ sudo groupadd vmwaregroup
[hua@zhanghua WindowsServer2012]$ sudo usermod -a -G vmwaregroup hua
[hua@zhanghua WindowsServer2012]$ id hua
uid=1000(hua) gid=1000(hua) groups=1000(hua),1001(libvirtd),1002(vmwaregroup)
[hua@zhanghua WindowsServer2012]$ sudo chgrp vmwaregroup /dev/vmnet8
[hua@zhanghua WindowsServer2012]$ sudo chmod g+rw /dev/vmnet8
[hua@zhanghua WindowsServer2012]$ ll /dev/vmnet8
crw-rw---- 1 root vmwaregroup 119, 8 Mar 20 09:49 /dev/vmnet8
[hua@zhanghua WindowsServer2012]$ sudo chmod a+rw /dev/vmnet8
[hua@zhanghua WindowsServer2012]$ ll /dev/vmnet8
crw-rw-rw- 1 root vmwaregroup 119, 8 Mar 20 09:49 /dev/vmnet8
sudo service vmware restart
上述方法在系统重启后会消失,A more permanent fix is to edit /etc/init.d/vmware on the Host, by adding the lines in red:
# Start the virtual ethernet kernel service
vmwareStartVmnet() {
vmwareLoadModule $vnet
"$BINDIR"/vmware-networks --start >> $VNETLIB_LOG 2>&1
chgrp vmwaregroup /dev/vmnet*
chmod a+rw /dev/vmnet*
下面是命令演示如何创建vmware桥:
vmnet-bridge -n 4 -i eth2 -d /var/run/vmnet-bridge-4.pid -1vmnet4
mknod /dev/vmnet4 c 119 4
vmnet-netifup -d /var/run/vmnet-netifup-vmnet4.pid /dev/vmnet4 vmnet4
ifconfig eth2 0.0.0.0 proimsc up
虚机中使用桥,将以下命令行内容添加到vmx文件:
ethetnet0.connectionType = "custom"
ethernet0.vnet = "vmnet4"
这里老外有个建议,说是最好用bridge,而不是nat, 如下:
you'll be able to boot your Guest VM, and use Wireshark or whatever in the Guest. Just Remember! Your VM Guest's Network Adapter must be set to BRIDGED (connected directly to the physical network), not NAT (used to share the host's IP address).
2.5 关于vmware中的vlan
vmware中的vlan有三种方式, 可参见Vmware ESX Server 3 802.1Q解决方案:http://wenku.baidu.com/view/90b76687ec3a87c24028c4b9.html
1, VGT 即在虚机里就打了标签, 将端口组的vlan_id属性设为4095(相当于端口组就设为TRUCK了), 并且在虚拟机中运行802.1Q VLAN trunking驱动。
2,EST 在外部交换机打标签, 默认行为,端口组的vlan_id属性为0,相当于disable掉了端口组的tag功能 。
3,VST 在vmware的虚拟交换机上打标签, vmware用了端口组的概念,所以想定义一个vlan的话就要定义一个端口组,在端口组的vlan_id属性设值(1-4094)。然后虚机和端口组关联。
To configure a VLAN on the portgroup using the VMware Infrastructure/vSphere Client:
Click the ESXi/ESX host.
Click the Configuration tab.
Click the Networking link.
Click Properties.
Click the virtual switch / portgroups in the Ports tab and click Edit.
Click the General tab.
Assign a VLAN number in VLAN ID (optional).
Click the NIC Teaming tab.
From the Load Balancing dropdown, choose Route based on originating virtual port ID.
Verify that there is at least one network adapter listed under Active Adapters.
Verify the VST configuration using the ping command to confirm the connection between the ESXi/ESX host and the gateway interfaces and another host on the same VLAN.
Note: For additional information on VLAN configuration of a VirtualSwitch (vSwitch) port group, see Configuring a VLAN on a portgroup (1003825).
Log into the ESXi/ESX host or vCenter Server using the vSphere Client.
Select the ESXi/ESX host in the inventory.
Click the Configuration tab.
In the Hardware section, click Networking.
Click Properties of the virtual switch for which you want to enable promiscuous mode.
Select the virtual switch or portgroup you wish to modify and click Edit.
Click the Security tab.
From the Promiscuous Mode dropdown menu, click Accept.
2013-04-05加: