This question is similar to No tun device in lxc guest for openvpn . The LXC has evolved and the unprivileged LXC containers were introduced recently that offer another layer of security against breaking the jail.
I need to create an OpenVPN server inside one of the unprivileged container. I don't know how to let the container create a private tun network device.
I did append lxc.cgroup.devices.allow = c 10:200 rwm
to the ~/.local/share/lxc/mylxc/config
.
After starting the container, mknod /dev/net/tun c 10 200
returns mknod: '/dev/net/tun': Operation not permitted
inside the container.
I use a vanilla Ubuntu 14.04 64bit as host and a container created with
lxc-create -t download -n mylxc -- -d ubuntu -r trusty -a amd64
Did anyone managed to get /dev/tun
device running under unprivileged LXC?
You need to explicitly add the CAP_MKNOD capability to your container.
You could also try to automate this (if you happen to use
systemd
inside the container) using:which can point to a script running
mknod
.Using
docker
this is very easy to accomplish. By default, containers are unprivileged.In this example, I'm pulling a
trusty
container from the registry:And I'm starting it in interactive mode informing about the capability I need inside:
As opposed to: