How to enable tun/tap inside LXC

In the future, using the website cloudhosting.lv, you agree to the rules of using Cookies. Read more. I agree

How to enable tun/tap inside LXC

To enable the tun/tap interface in a LXC container – eg. for openvpn – one needs to edit the LXC configuration file.

Its default location is:

/etc/lxc/default.conf

and you have to add:

lxc.cgroup.devices.allow = c 10:200 rwm

This works in proxmox 4.0, too.

To actually use a tun/tap device it must be created inside the container on every boot, so add the following to your /etc/rc.local inside your container:

if ! [ -d /dev/net ];then
 mkdir /dev/net
fi
if ! [ -c /dev/net/tun ]; then
 mknod /dev/net/tun c 10 200
 chmod 666 /dev/net/tun
fi

thats it!