Updated
At a glance
- Run the commands on the Proxmox node, not inside the container
- Proxmox VE 7 and later use the lxc.cgroup2 key
- The change takes effect after a container restart
- Check with ls -l /dev/net/tun inside the container
What the error means
A container shares the host kernel, so the TUN/TAP driver is the host's, but the container also needs two things: permission to use the character device (major 10, minor 200) and a device node at /dev/net/tun. Neither is granted by default. Typical messages are:
the system does not have the tun device availableCannot open TUN/TAP dev /dev/net/tun: No such file or directory/dev/net/tun: no such deviceoroperation not permitted
The fix is to allow the device in the container configuration and bind-mount the host's /dev/net/tun into it.
Prerequisites
- Root shell (SSH) on the Proxmox node that hosts the container.
- The container ID:
pct list. - The
tunkernel module loaded on the host. Check it and make it persistent if needed:
ls -l /dev/net/tun
lsmod | grep tun
modprobe tun
echo tun > /etc/modules-load.d/tun.confIf ls shows crw-rw-rw- 1 root root 10, 200 the host is ready.
Manual method
First find out which cgroup version the host uses:
stat -fc %T /sys/fs/cgroupThe answer cgroup2fs means cgroup v2, which is the default on Proxmox VE 7 and later. Edit /etc/pve/lxc/ID.conf (replace ID with the container number) and add, for cgroup v2:
lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=fileOn a cgroup v1 host the first line is lxc.cgroup.devices.allow: c 10:200 rwm instead. This is why older copies of this guide, which used the v1 key only, do not work on a current Proxmox: on a cgroup v2 host the v1 key has no effect. Then restart the container so the new configuration is applied:
pct stop ID
pct start ID Bash script
The script below checks the argument, finds the cgroup version, avoids adding the same lines twice and restarts the container only if it was running. Save it on the Proxmox node as enable-tuntap.sh:
#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -ne 1 ] || ! [[ "$1" =~ ^[0-9]+$ ]]; then
echo "Usage: $0 <container-id>" >&2
exit 1
fi
CTID="$1"
CONF="/etc/pve/lxc/${CTID}.conf"
if [ ! -f "$CONF" ]; then
echo "Config $CONF not found. Run this on the node that hosts container $CTID." >&2
exit 1
fi
if [ "$(stat -fc %T /sys/fs/cgroup)" = "cgroup2fs" ]; then
KEY="lxc.cgroup2.devices.allow"
else
KEY="lxc.cgroup.devices.allow"
fi
grep -q "^${KEY}: c 10:200 rwm" "$CONF" || echo "${KEY}: c 10:200 rwm" >> "$CONF"
grep -q "^lxc.mount.entry: /dev/net/tun" "$CONF" || echo "lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file" >> "$CONF"
if [ "$(pct status "$CTID")" = "status: running" ]; then
pct stop "$CTID"
pct start "$CTID"
fi
echo "TUN/TAP enabled for container ${CTID}"Make it executable and run it with the container ID:
chmod +x enable-tuntap.sh
./enable-tuntap.sh 101If the container was stopped, the script only edits the configuration and the device appears at the next start.
Verify inside the container
pct enter 101
ls -l /dev/net/tun
cat /dev/net/tunls should show a character device with major and minor numbers 10, 200; in an unprivileged container the owner may be shown as nobody. cat /dev/net/tun prints File descriptor in bad state: that message means the device opened correctly and is the expected result. Then start your VPN or tunnel service again.
Troubleshooting
- Still no device: check the lines with
grep lxc /etc/pve/lxc/ID.conf. A typo, a missing colon or a duplicated key is the usual cause. - Container on another node: in a cluster, run the commands on the node that currently runs the container.
- Container not restarted: the configuration is read at start. Stop and start the container; a reboot from inside it may not reload the configuration.
- Host without the module: if
/dev/net/tundoes not exist on the host, runmodprobe tunthere first.
Access to /dev/net/tun lets processes in the container create tunnel interfaces inside the container's own network namespace. Treat it as a privilege and enable it only for the containers that need it.
Running Proxmox on a dedicated server
Proxmox is a common hypervisor choice on dedicated hardware. On our dedicated servers you install the operating system yourself through IPMI/iDRAC, so you can put Proxmox on the machine and run LXC containers and KVM virtual machines side by side. See LXC vs KVM vs dedicated server for how to choose between them.
Frequently asked questions
Why does the container say the system does not have the tun device available?
Because the container has neither permission to use /dev/net/tun nor a device node for it. Add the cgroup device rule and the bind mount to the container configuration on the Proxmox host and restart the container.
Which key do I use on Proxmox VE 7 or 8?
lxc.cgroup2.devices.allow: c 10:200 rwm, because those releases use cgroup v2. The lxc.cgroup.devices.allow key is for cgroup v1 hosts.
Does this work for unprivileged containers?
Yes, the same two lines are used. The device node is owned by root on the host, so it appears as nobody inside an unprivileged container, which is expected.
Do I need to restart the container?
Yes. LXC reads the configuration when the container starts, so stop and start it after editing the file.
Does WireGuard need TUN?
The in-kernel WireGuard module does not, but userspace implementations such as wireguard-go, and tools like OpenVPN and Tailscale, do.
