Kernel TUN/TAP support (OpenVZ and similar environments)
Some environments (such as OpenVZ) require explicit configuration to allow containers to use the TUN/TAP device.
Make sure the TUN module is loaded on the host system:
lsmod | grep tun
If it is not loaded:
sudo modprobe tun
To ensure it loads on reboot, add it to your system configuration (e.g. /etc/modules or equivalent for your distribution).
Common issues
1. /dev/net/tun missing or permission denied
Check device:
ls -l /dev/net
If the device is missing or has incorrect permissions, recreate it:
sudo rm /dev/net/tun
sudo mknod /dev/net/tun c 10 200
sudo chmod 666 /dev/net/tun
2. Operation not permitted
Error:
Cannot create TUN device file node: operation not permitted
This usually means:
You are not running with sufficient privileges
The environment restricts device creation
Ensure you are using sudo and that your environment allows TUN devices.
3. Docker cannot access TUN device
If running in Docker, expose the device:
--device /dev/net/tun:/dev/net/tun
or in docker-compose:
devices:
- /dev/net/tun:/dev/net/tun
4. Module not found
Error:
modprobe: FATAL: Module tun not found
This indicates the TUN module is missing from your kernel.
Try:
Rebooting the system
Updating or reinstalling kernel modules
Check if the module exists:
find /lib/modules -iname tun\.*
If it is missing, your kernel may not support TUN.
Notes
TUN issues are typically caused by missing modules or restricted environments
VPS or container-based setups may require additional configuration
Restart your node after applying changes
