TUN is a virtual network kernel devices and is used for routing.
To enable TUN in an OpenVZ VPS1). SSH to your OpenVZ node or container.
2). Check whether TUN module is loaded. If it is not loaded use the below commands to load TUN modules.
[root@server ~]# lsmod | grep tun
[root@server ~]# modprobe tun
3). Check whether TUN is loaded now
[root@server ~]# lsmod | grep tun
tun 82176 0
4). Now allow the desired container to use TUN using following steps.
[root@server ~]#
vzctl set 999 --devices c:10:200:rw --saveSetting devices
Saved parameters for CT 999
[root@server ~]#
vzctl stop 999Stopping container ...
Container was stopped
Container is unmounted
[root@server ~]#
vzctl set 999 --capability net_admin:on --saveSaved parameters for CT 999
[root@server ~]# vzctl start 999
Starting container ...
Container is mounted
Adding IP address(es): x.x.x.x
Setting CPU limit: 400
Setting CPU units: 1000
Setting CPUs: 2
Setting devices
Set hostname: test.domainname.com
File resolv.conf was modified
Setting quota ugidlimit: 10000
Container start in progress...
5). Check whether TUN is available in VPS
[root@test ~]#cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state
Now you are all done and ready to go