OpenVZ Forum - RDF feed
type: channel
items: *SOLVED* Network script like vps.mount
items: Re: Network script like vps.mount

*SOLVED* Network script like vps.mount
type: item
description: Hi! I want to use my VEs in "bridged mode". I mean I want to use the veth devices not the venet. I added the veth* devices into a bridge at the end of the hosts boot process. Everything is working fine but when I restart the VE it's (of course) removed from the hosts bridge interface. I looked after it and found there is a vps.mount or $VEID.mount named script which automatically runs at the start of the VE. But it runs too early, the network interfaces aren't up at this time. Is there any script which runs automatically after the network initialization? I don't want to write a wrapper for vzctl just for this. Thanks for any help.
creator: arpad
date: 2007-01-19T14:05:22-00:00

Re: Network script like vps.mount
type: item
description: Make sure, that you're using vzctl not older then 3.0.14 and look at file /sbin/vznetcfg. This file is created exactly for this purposes. HTH, Vasily.
creator: Vasily Tarasov
date: 2007-01-19T15:43:00-00:00

Re: Network script like vps.mount
type: item
description: Vasily, There's no documentation in vznetcfg itself, there's no man page, and it's not mentioned anywhere else in the documentation distributed with the vzctl package. So, for posterity: vznetcfg (probably /usr/sbin/vznetcfg) is run by vzctl just after it creates the veth interfaces specified in your configuration. You can find the call in src/lib/veth.c in the vzctl distribution in the veth_ctl() function. The script is called like this: vznetcfg init veth <veth_device> E.g., vznetcfg init veth veth101.0 The environment variable VEID contains the current VEID. Unlike other scripts, VE_CONFFILE is not available so you'll have to calculate it yourself if you need it. Vasily et al: wouldn't it be simpler to set up the environment in the run_script() function so that it's the same for all scripts? The script is called once for each veth interface defined in your configuration file. If you set EXTERNAL_SCRIPT in /etc/vz/vznet.conf, vznetcfg will call this script with whatever arguments were originally passed to vznetcfg. The script is only called during startup -- if you need to do something special to unconfigure the interfaces you're on your own. I'm using the following EXTERNAL_SCRIPT (the BRIDGE variable is set in the VE configuration file. I should probably make this settable per-interface, rather than per-VE): #!/bin/sh . /etc/vz/conf/${VEID}.conf case $1 in (init) shift case $1 in (veth) shift dev=$1 if [ -n "$BRIDGE" ]; then echo "+ Adding $dev to bridge $BRIDGE." brctl addif $BRIDGE $1 fi ;; esac ;; esac
creator: larsks
date: 2007-01-20T02:14:40-00:00

Re: Network script like vps.mount
type: item
description: Hi! Thanks the script. I read the source of vznetcfg and wrote a similar myself before I read it :-) But anyway thanks for this script I got some extra ideas from it. Maybe this can be added to the official documentation too. Thanks, Arpad
creator: arpad
date: 2007-01-21T14:13:06-00:00

Re: Network script like vps.mount
type: item
description: Lars, Thank you very much for your detailed explanation. Can you, please, create a small wiki-page at wiki.openvz.org about vznetcfg? It will be really useful! Thank in advance, Vasily.
creator: Vasily Tarasov
date: 2007-01-24T07:59:27-00:00