Debian 6.0 Squeeze 上的 Xen 网桥问题

原先装过2台debian xen的服务器,一台是debian 4.0的,一台是debian 5.0 的,这一次装debian 6.0 的,被这个网桥给折磨了一整天.

原先的4.0和5.0两个版本的服务器均只启用一块网卡,配置一个网桥,一直以来也没注意多网桥有什么不同,这次6.0的服务器打算配2个网桥,本着外事不决问google的做法,搜出几个解决方案,照搬,重启,出错.

这两天就为这个来回折腾,中文的资料看完了,实在找不到办法,转到英文站点去,似乎有个人写了个脚本,说是6.0上使用的,xen 4.0后网桥脚本有所变动,顺着源码(/etc/xen/scripts/network-bridge)一直看下去,对比5.0的相同脚本的源码,终于发现了,确实是改动了.

xen 3.0的network-bridge默认创建xenbr0网桥,将eth0改为peth0,创建eth0虚拟网卡,并把peth0和eth0绑定到xenbr0上.

xen 4.0的network-bridge默认创建eth0网桥,将eth0改为peth0,并把peth0绑定到eth0上.

就这点不同,就耗费了我一整天时间,吐血啊.留个纪念,下次免得忘记.

附某个忘记名字的人写的针对debian6.0的多网桥启用脚本.

#!/bin/bash
# next two lines were good for xen-3.2.1 not for xen-4.0x anymore
#/etc/xen/scripts/network-bridge netdev=eth0 bridge=xenbr0 start
#/etc/xen/scripts/network-bridge netdev=eth1 bridge=xenbr1 start

# this works for xen-4.0x
# xen-utils-common in squeeze don't produce this script (yet) which is needed

if [ ! -f ../scripts/hotplugpath.sh ];then
    echo -e "SBINDIR=\"/usr/sbin\"
BINDIR=\"/usr/bin\"
LIBEXEC=\"/usr/lib/xen/bin\"
LIBDIR=\"/usr/lib\"
SHAREDIR=\"/usr/share\"
PRIVATE_BINDIR=\"/usr/lib/xen/bin\"
XENFIRMWAREDIR=\"/usr/lib/xen/boot\"
XEN_CONFIG_DIR=\"/etc/xen\"
XEN_SCRIPT_DIR=\"/etc/xen/scripts\"" > /etc/xen/scripts/hotplugpath.sh
    chown root:root /etc/xen/scripts/hotplugpath.sh
    chmod 755 /etc/xen/scripts/hotplugpath.sh
fi

/etc/xen/scripts/network-bridge netdev=eth0 start

# if you want to bind a NIC in domU to another interface in dom0 (bridging mode) than:
# 1.) list all dom0 interfaces you want to be able to use (except your eth0!) in "more_bridges" below
# 2.) in the domU config use: vif = [ 'mac=00:16:3e:xx:xx:xx, bridge=ethX' ] with ethX being the original device of dom0 that this domU should use
# 3.) using bridging, all interfaces in dom0 that you want to use  have to be valid configured BEFORE you run this script, i.e. before starting xend the first time.
#       (use ping -I ethX <target your gateway> to CHECK THAT BEFORE, and don't blame me if u plugged the cable into the wrong nic port ;-)
# 4.) remember, in the background xen does move the link to another name, creates a new interface etc etc... we don't care about this here, it just works fine for now

# here I want to prepare to other nics that I can choose from in the domU configs
more_bridges="eth1 eth2"

for i in $more_bridges; do
    ip addr show dev $i | egrep inet > /dev/null 2>&1
    if [ $? == 0 ];then
        ip link set $i down
        /etc/xen/scripts/network-bridge netdev=$i start
        ip link set $i up
    else
        echo -e "\nFailed to set up a bridge!\nYour device $i in dom0 seems not to be configured, so I won't try to use it as part of a bridge for any domU\n"
    fi
done

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wywdyg.html