Search code examples
linuxroutescentoscontainersopenvz

OpenVZ change default route in CentOS 6


Environment: CentOS 6.7 as host system, OpenVZ container with CentOS 6.7 too.

Container have 2 interfaces: venet0 (10.50.140.160, in vxbr0 of host) and eth1 (10.30.30.3/24, in br1 of host)

I want to use venet0 for ssh connect and set default gateway of container to another host (10.30.30.1) in br1 via eth1.

So, my configs:

https://gist.github.com/strizhechenko/e821ff5b165acc7475eb

and problem is: after apply changes by service network restart, default route reset to "dev venet0". Is it some OpenVZ magic or I missed something important?

An alternative way - run this container in LXC, but LXC isn't compatible with OpenVZ kernel (I have troubles with mount /cgroups/ -> troubles with lxc-start).


Solution

  • Found out a "problem".

    Default route wasn't magic, it was set in /etc/sysconfig/network in options GATEWAYDEV and IPV6_DEFAULTDEV, so I replace venet0 to eth1 and everything is find.

    # cat /etc/sysconfig/network
    NETWORKING="yes"
    GATEWAYDEV="eth1"
    NETWORKING_IPV6="yes"
    IPV6_DEFAULTDEV="eth1"
    HOSTNAME="centos-user"