Enable TUN / TAP in OpenVZ

08. September 2015 SysAdmin 0

Issue

You have an OpenVZ VPS and you are getting the following error.

[[email protected] ~]# cat /dev/net/tun
cat: /dev/net/tun: No such device

Fix

Makes sure you have TUN / TAP enabled on the Hardware node.

lsmod | grep tun

If it didnt return anything, run the below and make sure the module is loaded.

lsmod | grep tun

From your OpenVZ Hardware node, Run the below to enable TUN/TAP for the VPS. Note : CTID is the ID you get from the command

vzlist -a – Stop the VPS by running

vzctl stop CTID 

Then run,

vzctl set CTID --devnodes net/tun:rw --capability net_admin:on --save

– Then start the vps by running,

vzctl start CTID 

  • Now login to the VPS, and check the TUN/TAP status

vzctl enter CTID 

[[email protected] ~]# cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state

The above message means, Your VPS has now TUN/TAP enabled.


Leave a Reply

Your email address will not be published.