How to enable TUN/TAP for OpenVZ server

SolusVM requires the TUN/TAP kernel module to be loaded for the TUN/TAP feature to work properly.
To enable the TUN/TAP kernel module run this on the host node:
Code: Select all
#modprobe tun

To check if it’s loaded run:
Code: Select all
#lsmod | grep tun
If you see an output the module is loaded i.e:
Code: Select all
tun                    17536  0
Too automatically load the module on boot run these commands on the host node:
Code: Select all
echo modprobe tun >> /etc/rc.modules
chmod +x /etc/rc.modules
OpenVZ supports VPN inside a container via kernel TUN/TAP module and device.
 To allow VPS #205 to use the TUN/TAP device the following should be done:

#205 – VPS id. Replace 205 with your VPS id.
Make sure the tun module has already loaded on the Node.
[root@Node /]#  lsmod | grep tun
If not listed, then load the tun module with the below command
[root@Node /]# modprobe tun
[root@Node /]#  lsmod | grep tun
  tun                    82432  6
Run the following command in VPS Node:

[root@VPS Node /]# vzctl set 508 --devVPS Nodes net/tun:rw --save
[root@VPS Node /]# vzctl set 508 --devices c:10:200:rw --save
[root@VPS Node /]#  vzctl stop 508
[root@VPS Node /]# vzctl set 508 --capability net_admin:on --save
[root@VPS Node /]# vzctl start 508
[root@VPS Node /]# vzctl exec 508 mkdir -p /dev/net
[root@VPS Node /]# vzctl exec 508 chmod 600 /dev/net/tun
To check TUN/TAP is enabled or not:
[root@VPS Node /]# vzctl enter 508
 Inside the VPS:
[root@vps /]# cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state 
It means the TUN/TAP is enabled on your VPS.
#cat: /dev/net/tun: No such device 
If you receive like this, then the TUN/TAP has not enabled on your VPS. Try to enable TUN/TAP again and check.

Comments

Popular Posts

Install and configure rsyslog Centralized logging server in CentOS

How to fix postfix/smtp Network is unreachable error

Could not join realm: Necessary packages are not installed: sssd-tools sssd libnss-sss libpam-sss adcli