OpenVZ Forum


Home » Mailing lists » Users » Network configuration
Network configuration [message #24979] Wed, 12 December 2007 16:30 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
Re: Network configuration [message #27352 is a reply to message #24979] Wed, 13 February 2008 17:15 Go to previous message
b52_ is currently offline  b52_
Messages: 2
Registered: February 2008
Junior Member
From: openvz.org
>so the question is :
>
>is it possible to know in the EXTERNAL_SCRIPT, for which interface, the
>script is execute ?

Hi,

your script will be executed with parameters.

I tried this to find them out:

mrwhite:/# cat /etc/vz/vznet.conf
EXTERNAL_SCRIPT="/opt/sbin/vznetaddnet"

mrwhite:/# cat /opt/sbin/vznetaddnet
#!/bin/bash
echo $@

and while startup this prints:
init veth veth101.10
init veth veth101.20

bye,b52
Previous Topic: fake swap != 0 in VE?
Next Topic: calculation of resource values (numfiles)
Goto Forum:
  


Current Time: Sun May 27 19:26:49 GMT 2018