cd /etc/sysconfig/network-scripts
touch ifcfg-xenbr2 ifcfg-eth0.2
ifcfg-xenbr1 ifcfg-eth0.1的内容如下:
[root@XenServer network-scripts]# cat ifcfg-xenbr2
DEVICE=xenbr2
BOOTPROTO=static
ONBOOT=yes
TYPE=Bridge
[root@XenServer network-scripts]# cat ifcfg-eth0.2
DEVICE=eth0.2
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
VLAN=yes
BRIDGE=xenbr2
创建了这两个文件后,依次使用命令:
ifup ifcfg-xenbr2
ifup ifcfg-eth0.2
这样就可以首先创建一个叫xenbr2的网桥,然后,把eth0.2桥接到该往桥上,所以,启动的顺序不可反过来。
然后,在domu的配置中,使用网桥的配置改为:
vif = [ "bridge=xenbr1,script=vif-bridge" ]
不过这时候别忘记在物理端口直连的交换机端口上开启trunk,使用8021q的标签/。
Enjoy it!计算机
附上其他的解决方法
xen 3.0.3 - create 3 alias with the only one NIC and 3 vlan with each alias interface
Preparation
Install Vlan Config tool
yum install vconfig
modprobe 8021q
vi /etc/sysconfig/modules/8021q.modules
modprobe 8021q
chmod a+x /etc/sysconfig/modules/8021q.modules
create 3 alias with the only one NIC
copy configuration file
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.2
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.3
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.4
edit example
vi /etc/sysconfig/network-scripts/ifcfg-eth0.4
DEVICE=eth0.4
BOOTPROTO=static
DHCPCLASS=
IPADDR=10.4.100.73
NETMASK=255.255.255.0
VLAN=yes
ONBOOT=yes
Announcements:each alias interface does not need to config ip address,the purpose for that just want to test whether it works.eth0 should not have any ip address(i.e. the same network segment as the default gateway ),because the other network segment will match the rule (10.1.100.0 to eth0),and by default the bridges created by xen
cannot talk with each other.
计算机基础知识教程
create custom script for vlan
main function script
cp /etc/xen/scripts/network-bridge /etc/xen/scripts/network-bridge-vlan
vi /etc/xen/scripts/network-bridge-vlan
#DL# if is_bonding ${netdev} || ! ifdown ${netdev}; then
# Remember the IP details if necessary.
get_ip_info ${netdev}
ip link set ${netdev} down
ip addr flush ${netdev}
#DL# fi
#DL# if ! ifdown ${netdev}; then
get_ip_info ${netdev}
#DL# fi
chmod a+x /etc/xen/scripts/network-bridge-vlan
create main script for load
vi /etc/xen/scripts/network-bridge-withvlan
#!/bin/sh
function call_network_bridge
{
dir=/etc/xen/scripts
"$dir/network-bridge-vlan" "$@" netdev=eth0 vifnum=0 bridge=xenbr0
"$dir/network-bridge-vlan" "$@" netdev="eth0.2" vifnum=1 bridge=xenbr0V2
"$dir/network-bridge-vlan" "$@" netdev="eth0.3" vifnum=2 bridge=xenbr0V3
"$dir/network-bridge-vlan" "$@" netdev="eth0.4" vifnum=3 bridge=xenbr0V4
}
case "$1" in
start)
echo "start"
vconfig set_name_type DEV_PLUS_VID_NO_PAD
vconfig add "eth0" 2
vconfig add "eth0" 3
vconfig add "eth0" 4
call_network_bridge start
;
stop)
echo "stop"
call_network_bridge stop
vconfig rem "eth0.2"
vconfig rem "eth0.3"
vconfig rem "eth0.4"
;
esac
chmod a+x /etc/xen/scripts/network-bridge-withvlan
Change xend config
vi /etc/xen/xend-config.sxp
(network-script network-bridge-withvlan)
to validate mentioned in inhttp://wiki.xensource.com/xenwiki/XenNetworking
[root:/etc/xen]# cat /etc/init.d/xen-vlan
#!/bin/sh
ethtool -K eth0 tx off
查看更多