Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to enable TUN in OpenVZ Server  (Read 3450 times)

0 Members and 1 Guest are viewing this topic.

Vinil

  • Guest
How to enable TUN in OpenVZ Server
« on: December 31, 2013, 10:20:56 pm »
TUN is a virtual network kernel devices and is used for routing.

To enable TUN in an OpenVZ VPS


1). 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.

Quote
[root@server ~]# lsmod | grep tun
[root@server ~]# modprobe tun

3). Check whether TUN is loaded now

Quote
[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 --save
Setting devices
Saved parameters for CT 999


[root@server ~]# vzctl stop 999
Stopping container ...
Container was stopped
Container is unmounted


[root@server ~]# vzctl set 999 --capability net_admin:on --save
Saved parameters for CT 999


Quote
[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


Quote
[root@test ~]#cat /dev/net/tun

cat: /dev/net/tun: File descriptor in bad state


Now you are all done and ready to go  :)