OpenVZ Forum


Home » Mailing lists » Users » Network configuration
Network configuration [message #24977] Wed, 12 December 2007 17:01 Go to next message
Yoann Moulin is currently offline  Yoann Moulin
Messages: 16
Registered: December 2007
Junior Member
From: openvz.org
Hi all,

I'm currently working on a xen to openvz migration and some I have problem to setup the network configuration.

I'm using the lastest kernel patch build to support nfsroot for the openvz host under ubuntu dapper 6.06 LTS

I will have at least 12 vlan on the OVZ host, and 2 or 3 vlan in each VE

for example, NETIF for the VEID 101

NETIF="ifname=eth1.10,mac=00:16:3E:00:00:1E,host_ifname=veth101.10,host_mac=00:E0:81:4B:2F:DB;ifname=eth1.19,mac=00:16:3E:00:00:1E,host_ifname=veth101&.19,host_mac=00:E0:81:4B:2F:DB"

and I want an EXTERNAL_SCRIPT that check if the bridge exist, and if not create and add the interface

my first idea was adding a new variable that indicate all the vlan we have to configure :

VETH_BRIDGE="brvlan10 brvlan19"

with this script :

---- BEGIN SCRIPT ----
#!/bin/bash
# /usr/sbin/vznetaddroute
# a script to bring up virtual network interfaces (veth's) in a VE
CONFIGFILE=/etc/vz/conf/$VEID.conf
. $CONFIGFILE
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\)\..*,.*$/\1/g'`

for BRIDGE in ${VETH_BRIDGE} ; do

         VLAN=`echo ${BRIDGE} | sed 's/brvlan//'`

         if [ ! -n "${VZHOSTIF}.${VLAN}" ]; then
                 echo "According to $CONFIGFILE VE$VEID has no veth interface configured."
                 exit 1
         fi

         if [ ! -n "${BRIDGE}" ]; then
            echo "According to $CONFIGFILE VE$VEID has no veth bridge configured."
            exit 1
         fi

         echo "Adding interface ${VZHOSTIF}.${VLAN} to bridge ${BRIDGE} on VE0"

         if [ -z "`/usr/sbin/brctl show | /bin/grep ${BRIDGE}`" ]; then
            /usr/sbin/brctl addbr ${BRIDGE}
            /usr/sbin/brctl addif ${BRIDGE} eth1.${VLAN}
            /sbin/ip link set ${BRIDGE} up
         fi

         /usr/sbin/brctl addif ${BRIDGE} ${VZHOSTIF}.${VLAN}
         /sbin/ip link set ${VZHOSTIF}.${VLAN} up
done

exit 0
---- END SCRIPT ----

When I start my VE, I have :

# vzctl start 101
Starting VE ...
VE is mounted
Setting CPU limit: 241132
Setting CPU units: 55555
Configure meminfo: 502650
Set hostname: adviseo03
Configure veth devices: veth101.10 veth101.19
Adding interface veth101.10 to bridge brvlan10 on VE0
Adding interface veth101.19 to bridge brvlan19 on VE0
interface veth101.19 does not exist!
SIOCGIFFLAGS: No such device
Adding interface veth101.10 to bridge brvlan10 on VE0
device veth101.10 is already a member of a bridge; can't enslave it to bridge brvlan10.
Adding interface veth101.19 to bridge brvlan19 on VE0
VE start in progress...

so at start vzctl already know we will have 2 net device : "Configure veth devices: veth101.10 veth101.19"

so the EXTERNAL_SCRIPT is execute 2 times, one time for each veth, so I shouldn't need to setup VETH_BRIDGE if in the
EXTERNAL_SCRIPT, I'm able to know with veth is currently configured

It's not easy to explain until it is still quite complicated for me

so the question is :

is it possible to know in the EXTERNAL_SCRIPT, for which interface, the script is execute ?

thanks for your help

Yoann
ps : already sent this message at 5:30pm GMT+1 but not arrived yet a 6:00 GMT+1
Re: Network configuration [message #24984 is a reply to message #24977] Wed, 12 December 2007 17:57 Go to previous message
Yoann Moulin is currently offline  Yoann Moulin
Messages: 16
Registered: December 2007
Junior Member
From: openvz.org
> is it possible to know in the EXTERNAL_SCRIPT, for which interface, the
> script is execute ?

Well, I gave a look to the source code and got my answer ($3)... it's working perfectly.

NETIF still the same :

NETIF="ifname=eth1.10,mac=00:16:3E:00:00:1E,host_ifname=veth10.10,host_mac=00:E0:81:4B:2F:DB;ifname=eth1.19,mac=00:16:3E:00:00:1E,host_ifname=veth10.19,host_mac=00:E0:81:4B:2F:DB"

and the script begin :

---- BEGIN SCRIPT ----
#!/bin/bash
# /usr/sbin/vznetaddroute
# a script to bring up virtual network interfaces (veth's) in a VE
CONFIGFILE=/etc/vz/conf/$VEID.conf
. $CONFIGFILE
VETH=$3
VZHOSTIF=`echo ${VETH} | cut -f1 -d"."`
VLAN=`echo ${VETH} | cut -f2 -d"."`
VETH_BRIDGE=brvlan${VLAN}

if [ ! -n "${VZHOSTIF}.${VLAN}" ]; then
         echo "According to $CONFIGFILE VE$VEID has no veth interface configured."
         exit 1
fi

if [ ! -n "${VETH_BRIDGE}" ]; then
    echo "According to $CONFIGFILE VE$VEID has no veth VETH_BRIDGE configured."
    exit 1
fi

echo "Adding interface ${VZHOSTIF}.${VLAN} to VETH_BRIDGE ${VETH_BRIDGE} on VE0"

if [ -z "`/usr/sbin/brctl show | /bin/grep ${VETH_BRIDGE}`" ]; then
    /usr/sbin/brctl addbr ${VETH_BRIDGE}
    /usr/sbin/brctl addif ${VETH_BRIDGE} eth1.${VLAN}
    /sbin/ip link set ${VETH_BRIDGE} up
fi

/usr/sbin/brctl addif ${VETH_BRIDGE} ${VZHOSTIF}.${VLAN}
/sbin/ip link set ${VZHOSTIF}.${VLAN} up
exit 0
---- END SCRIPT ----

sorry for the noise

Yoann
Previous Topic: Dns resolution failure..
Next Topic: strange problem with nagios nrpe server
Goto Forum:
  


Current Time: Wed Dec 12 11:34:05 GMT 2018