|
|
|
|
|
|
|
|
|
|
xen-users
Re: [Xen-users] Network-bridge with VLAN
2008/11/6 Gael Reignier <gael@xxxxxxxxxx>
Any help will be much appreciate as this issue starts to drive me crazy
and I do not know where to start looking... so if you spot any problem
or that I should do something else, just let me know :-) Before you get crazy, try this script, I spent several weeks to get it working. The first part dynamically create the VLAN IF (eth0.x) and the associated bridge (xenbrx). The second one creates config files to make it up at the next reboot.
This is the script (sorry for french comments):
--->8--- #!/bin/bash # A. Barthe -- jeu nov 22 14:14:18 CET 2007 # Script de fabrication dynamique d'un VLAN pour un dom0 xen # Parametres: <vlan tag> [device] (device par defaut: eth0)
#
#DEBUG=echo
script=$(basename $0) USAGE="Usage: $script <vlan tag> [device] (device par defaut: eth0)"
if [ $# -ne 1 -a $# -ne 2 ]; then echo $USAGE >&2 exit 1
fi
#-------------------------------------------------------------------- # FABRICATION DYNAMIQUE DU VLAN ET DU BRIDGE ASSOCIE
vtag=$1 dev=${2:-eth0}
ifconfig | grep -q p$dev || { echo "p$dev: interface non trouvee" >&2
exit 1 }
# Creation du VLAN sur pethx $DEBUG modprobe 8021q $DEBUG vconfig add p$dev $vtag || { echo "Echec a la creation du VLAN" >&2 exit 1 }
# Renommage de pethx.y en ethx.y
$DEBUG ip link set p$dev.$vtag name $dev.$vtag
# Recuperation de la MAC de $dev mac=$(ifconfig $dev | head -1 | awk '{print $NF}')
# Affectation de la MAC a l'interface just created ip link set $dev.$vtag address $mac
# Configuration du VLAN $DEBUG ip link set $dev.$vtag promisc on $DEBUG ip link set $dev.$vtag multicast on $DEBUG ip link set $dev.$vtag arp on
# Creation du bridge et ajout du VLAN dessus $DEBUG brctl addbr xenbr$vtag
$DEBUG brctl addif xenbr$vtag $dev.$vtag
# Demarrage du VLAN et du bridge $DEBUG ifconfig $dev.$vtag up $DEBUG ifconfig xenbr$vtag up
#--------------------------------------------------------------------
# FABRICATION DES FICHIERS DE DEMARRAGE POUR QUE CA MARCHE AU REBOOT
root="/etc/sysconfig/network-scripts" #root="toto" baseif="ifcfg-"
iffile="$root/$baseif$dev"
test -f $iffile || { echo "$iffile: fichier non trouve" >&2 exit 1 }
# Rajout du flag VLAN dans le fichier de demarrage de l'interface grep -q "VLAN=yes" $iffile || echo "VLAN=yes" >> $iffile
# Fabrication du fichier de demarrage du vlan vlanfile="$iffile.$vtag" cat > $vlanfile <<EOF DEVICE=$dev.$vtag BOOTPROTO=none >TYPE=Ethernet VLAN=yes BRIDGE=xenbr$vtag
EOF
# Fabrication du fichier de demarrage du bridge associe brfile="$root/${baseif}xenbr$vtag" cat > $brfile <<EOF DEVICE=xenbr$vtag BOOTPROTO=none >TYPE=Bridge EOF
# Et voila... echo "Le VLAN $dev.$vtag et le bridge xenbr$vtag ont bien ete crees." --->8---
Hope this helps.
Alain.
So thanks a million in advance for any of your help!
Cheers
Gael
_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users
_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users
|
|
|
|
|