Openvz offers two options to connect your containers to the network: venet and veth. Read about the differences here
I’m doing this install on a centos 5.2 and ovzkernel 2.6.18.
You need bridge-utils package:
yum install bridge-utils
Adding a veth to a virtual machine is easy enough:
vzctl set 110 --netif_add eth0 --save
The problem is that nothing works actually out of the box, since the kernel doesn’t know what to do with the packages that get out of the virtual ethernet devices thus created (veth110.0 in our case).
We either setup a route for each virtual machine, or we can setup a bridge for it.
Create a file in /etc/sysconfig/network-scripts/ifcfg-en0. Take the ipaddr, netmask, network from your eth setup.
cat > /etc/sysconfig/network-scripts/ifcfg-en0
# Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express
DEVICE=en0
TYPE=Bridge
BOOTPROTO=static
IPADDR=10.80.130.24
NETMASK=255.255.255.0
NETWORK=10.80.130.0
GATEWAY=10.80.130.5
USERCTL=no
IPV6INIT=no
FREEDNS=no
ONBOOT=yes
Now set your eth to join the bridge:
DEVICE=eth0
BRIDGE=en0
HWADDR=00:1E:C9:D7:C8:9B
ONBOOT=yes
Now we could write a file for each veth but it’s painful to maintain, thus we modify a script a bit so that this is added each time you setup or restart a veth: /usr/sbin/vznetcfg
Replace:
init_veth()
{
local dev="$1"
ip link set "$dev" up
}
With:
init_veth()
{
local dev="$1"
ip link set "$dev" up
/usr/sbin/brctl addif en0 $dev
}
Now restart your network with
/etc/init.d/network restart
Enjoy
This documentation is provided under the freebsd license: http://www.freebsd.org/copyright/freebsd-doc-license.html
Alexandru Bordei
Advanced Technologies Specialist @ Hostway Corporation