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