To enable the tun device in OpenVZ containers, the tun module
I’ve grabbed the container configuration from askubuntu.
Edit tun.modules:
1# vim /etc/sysconfig/modules/tun.modules
2#!/bin/sh
3/sbin/modprobe tun
Set permissions for tun.modules:
1chmod 755 /etc/sysconfig/modules/tun.modules
Reboot the host system and test that the tun module is loaded:
1$ lsmod | grep tun
2tun 15493 2
Issue the following commands in the host terminal as root (change ‘101’ to your container ID):
1vzctl set 101 --devnodes net/tun:rw --save
2vzctl set 101 --devices c:10:200:rw --save
3vzctl set 101 --capability net_admin:on --save
4vzctl exec 101 mkdir -p /dev/net
5vzctl exec 101 mknod /dev/net/tun c 10 200
6vzctl exec 101 chmod 600 /dev/net/tun
Now configured OpenVPN will work correctly.