Enabling TUN/TAP Device on a VPS

From Ubiquity Server Wiki

Jump to: navigation, search

In order to run any sort of traffic tunneling application, or sometimes to even run a firewall - it's necessary to enable the TUN and TAP devices on your VPS. This cannot be done from the VPS itself, it must be done from the hardware node. "VZID" throughout this article is used to refer to the container ID of the VPS in question.

STEP ONE

Connect to the host node via SSH as the root user.

STEP TWO

Now we are going to enable the TUN device on the server.

modprobe tun

Once this is enabled, we will allow the VPS to access the TUN device.

vzctl set VZID --devices c:10:200:rw --save
vzctl set VZID --capability net_admin:on --save

Now that the VPS has access to the device, we will enable it on the VPS.

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

And you're all set! The VPS is now able to fully utilize the TUN/TAP devices, and can run OpenVPN properly.

Personal tools