Problem passing through /dev/net/tun to an LXC Container

jasont7

New Member
Oct 11, 2024
3
0
1
I have an unprivileged LXC running docker.
Docker is running a container called Gluetun.
Gluetun is supposed to be configured with either OpenVPN or Wireguard. Here is an example of the docker run:

Code:
docker run -it --rm --cap-add=NET_ADMIN -e VPN_SERVICE_PROVIDER=torguard \
-e OPENVPN_USER=abc -e OPENVPN_PASSWORD=abc \
-e SERVER_COUNTRIES=Netherlands qmcgaw/gluetun

But when I create the container, it returns the error:

Code:
2024-10-16T21:44:20Z INFO TUN device is not available: open /dev/net/tun: no such file or directory; creating it...
2024-10-16T21:44:20Z INFO [routing] routing cleanup...
2024-10-16T21:44:20Z INFO [routing] default route found: interface eth0, gateway 172.17.0.1, assigned IP 172.17.0.3 and family v4
2024-10-16T21:44:20Z INFO [routing] deleting route for 0.0.0.0/0
2024-10-16T21:44:20Z ERROR creating tun device: creating TUN device file node: operation not permitted

This looks like a permissions error.

I followed the OpenVPN guide in the wiki.

In my <id>.conf file for the lxc container I have the two lines:

Code:
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
lxc.cgroup2.devices.allow: c 10:200 rwm

I also made sure to run the chown command.

Code:
chown 100000:100000 /dev/net/tun

Code:
root@pve:~# ls -l /dev/net/tun
crw------- 1 100000 100000 10, 200 Oct 13 16:56 /dev/net/tun

and inside the LXC container:
Code:
root@my-lxc-container:~# ls -l /dev/net/tun
crw-rw-rw- 1 root root 10, 200 Oct 17 13:07 /dev/net/tun

But I still get the same error message:
Code:
2024-10-16T21:44:20Z ERROR creating tun device: creating TUN device file node: operation not permitted

What am I supposed to be doing?
If I make the LXC container privileged, it works just fine. For some reason Proxmox refuses to allow the container to use /dev/net/tun while it is unprivileged, even though I've made all the necessary provisions.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!