Table of content

www.kudos.be

Apr-08 - OpenVZ failing to assign IP address

Created Wednesday 08 April 2015

I was presented with quite an unpleasant surprise today when I rebooted a few OpenVZ containers running CentOS 7 with the latest patches applied. Though each of the reboots appeared to be going fine, the virtual ethernet (venet0) interfaces did not get properly initialized with its usual public IP address:

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
		inet 127.0.0.1  netmask 255.0.0.0
		inet6 ::1  prefixlen 128  scopeid 0x10<host>
		loop  txqueuelen 0  (Local Loopback)
		RX packets 12359  bytes 8562348 (8.1 MiB)
		RX errors 0  dropped 0  overruns 0  frame 0
		TX packets 12359  bytes 8562348 (8.1 MiB)
		TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

venet0: flags=211<UP,BROADCAST,POINTOPOINT,RUNNING,NOARP>  mtu 1500
		inet 127.0.0.1  netmask 255.255.255.255  broadcast 0.0.0.0  destination 127.0.0.1
		unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 0  (UNSPEC)
		RX packets 431683  bytes 454960074 (433.8 MiB)
		RX errors 0  dropped 0  overruns 0  frame 0
		TX packets 242391  bytes 38057183 (36.2 MiB)
		TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

As Google often turns out to be mine and your best friend in such cases, it did come up with a valid answer to the problem:

RHEL 7.1 VPS - initscripts upgrade causes networking failures: http://forum.openvz.org/index.php?t=rview&goto=51961&th=12869

The clue to the solution being to add following line to the /etc/vz/dists/scripts/redhat-add_ip.sh script on the hardware node:

ARPCHECK=\"no\"

in the function create_config():

function create_config()
{
		 local ip=$1
		 local netmask=$2
		 local ifnum=$3
		 local file=${IFCFG_DIR}/bak/${VENET_DEV_CFG}:${ifnum}
  
		 echo "DEVICE=${VENET_DEV}:${ifnum}
 ONBOOT=yes
 ARPCHECK=\"no\"
 IPADDR=${ip}
 NETMASK=${netmask}" > $file ||
		 error "Can't write to file $file" ${VZ_FS_NO_DISK_SPACE}
}

A fully patched version the script can be found here: http://git.openvz.org/?p=vzctl;a=blob;f=etc/dists/scripts/redhat-add_ip.sh

Rebooting the containers a second time confirmed that the script fix was sufficient to get the IP address assigned again:

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
		inet 127.0.0.1  netmask 255.0.0.0
		inet6 ::1  prefixlen 128  scopeid 0x10<host>
		loop  txqueuelen 0  (Local Loopback)
		RX packets 12359  bytes 8562348 (8.1 MiB)
		RX errors 0  dropped 0  overruns 0  frame 0
		TX packets 12359  bytes 8562348 (8.1 MiB)
		TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

venet0: flags=211<UP,BROADCAST,POINTOPOINT,RUNNING,NOARP>  mtu 1500
		inet 127.0.0.1  netmask 255.255.255.255  broadcast 0.0.0.0  destination 127.0.0.1
		unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 0  (UNSPEC)
		RX packets 431683  bytes 454960074 (433.8 MiB)
		RX errors 0  dropped 0  overruns 0  frame 0
		TX packets 242391  bytes 38057183 (36.2 MiB)
		TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

venet0:0: flags=211<UP,BROADCAST,POINTOPOINT,RUNNING,NOARP>  mtu 1500
		inet 15.2.3.4  netmask 255.255.255.255  broadcast 15.2.3.4  destination 15.2.3.4
		unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 0  (UNSPEC)



Backlinks: Journal:2015