Skip to content

Latest commit

 

History

History
92 lines (59 loc) · 3.56 KB

tun.md

File metadata and controls

92 lines (59 loc) · 3.56 KB

TUN device common errors

Visitors count

There can be various issues regarding the TUN device depending on your host environment.

cannot Unix Open TUN device file: operation not supported

This usually means you do not have the tun kernel module.

Usually loading the module on your host with insmod /lib/modules/tun.ko or modprobe /lib/modules/tun.ko should do the trick.

Otherwise you might have to re-compile your Kernel with the tun module.

cannot Unix Open TUN device file: no such device

This is still unclear why this is caused, but probably running the container with --device /dev/net/tun solves it.

cannot create TUN device file node: operation not permitted

This can happen when running LXC containers.

  1. Find your LXC container number, let's call it 12345

  2. Edit /etc/pve/lxc/12345.conf and add:

    lxc.cgroup2.devices.allow: c 10:200 rwm
    lxc.mount.entry: /dev/net dev/net none bind,create=dir
    lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
    
  3. In your run command or docker-compose.yml, use:

    --device /dev/net/tun:/dev/net/tun

    or

    devices:
      - /dev/net/tun:/dev/net/tun

Thanks to @Vendetta1985, source comment

TUN device is not available: open /dev/net/tun: permission denied

This can happen with podman. The only way known is to run the container with --privileged.

Thanks to @OkanEsen, source comment

cannot Unix Open TUN device file: operation not permitted and cannot create TUN device file node: operation not permitted

This happens on LXC containers.

  1. Find your container number, let's call it 12345

  2. Edit /etc/pve/lxc/12345.conf and add:

    lxc.cgroup2.devices.allow: c 10:200 rwm
    lxc.mount.entry: /dev/net dev/net none bind,create=dir
    lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
    
  3. In your run command or docker-compose.yml, use:

    --device /dev/net/tun:/dev/net/tun

    or

    devices:
      - /dev/net/tun:/dev/net/tun

🙏 thanks to @user037951, source discussion. 🙏 thanks to @Vendetta1985, source comment

creating TUN device file node: file exists

Either:

  • You need to run your Docker command as root by prefixing it with sudo. 🙏 thanks to @jnelle, source comment
  • You have a mismatch between your Kernel and the installed tun module. This can happen when upgrading your system and not rebooting. A simple reboot might fix it. 🙏 thanks to @aviolaris, original issue
  • Validate if the module tun is loaded correctly in the current kernel, see the original issue