Axel's root Blog

for nerds only - little stories from the everyday sysadmin life with problems and their hard-to-find solutions

OpenVZ with VEs in different subnet

2009-11-08 by Axel Reinhold, tagged as network, openvz
My hosting company supplies additional IPs for my server in a different subnet as the main IP for the server. This is not directly supported by OpenVZ.

The solution in the corresponding article of OpenVZs wiki recommends a rather tricky configuration with bridging the ethernet interface and using veth instead of vnet for the container. This is complicated and slow.

The main (hostnode) ip address for the server was 189.139.33.20/26. The additional ips were 189.139.35.37/25 and 189.139.35.38/25. Without finding an ethernet interface for the additional ips OpenVZ could only use these ips for containers with a bridge/veth or complicated iptables/NAT setup.

I tried to "ifconfig eth0:0 189.139.35.127/25 -arp" with using the containers subnet broadcast address for an ethernet subinterface. This simple setup made the whole thing work with vnet immediately.

Later i discovered that a simple route to the subnet via the ethernet interface is also completely sufficient: "route add -net 189.139.35.0/25 dev eth0"