Recently, playing around with my network settings, I encountered a few issues, that I have documented below for you, and how I fixed them.
qemu-system-x86_64: could not open /dev/net/tun: Permission denied
This means that your /dev/net/tun file has the incorrect permissions
The correct permissions are crw-rw-rw-
The following snippet removes the regular file, if any, and creates a Linux special file NAME of the given TYPE.
Note your current permissions and compare them with the following output:
ls -l /dev/net # crw-rw-rw- 1 root root 10, 200 May 18 23:34 tun
If your /dev/net/tun does not look like that, run the following to recreate that special file:
sudo rm /dev/net/tun sudo mknod /dev/net/tun c 10 200 sudo chmod 666 /dev/net/tun # check again now ls -l /dev/net
chmod: changing permissions of ‘/dev/net/tun’: Operation not permitted
This means you’re most like not super-user (sudo).
However, you should never see this message unless you were trying to run:
sudo chmod 666 /dev/net/tun
Once you’ve correctly re-created /dev/net/tun, you can modprobe it:
sudo modprobe tun
If you received an error here, there are other issues, possibly there is a network profile, service or card that is incompatible with your current kernel.
You should see the following:
grep CONFIG_TUN /usr/src/linux/.config # CONFIG_TUN=m
This command will verify what’s in your kernel ring buffer:
dmesg | grep TUN # [ 12.3456] tun: Universal TUN/TAP device driver, 1.6
If you’ve passed all of the above steps, then TUN is ready, it’s just needs to be turned on!
sudo modprobe tun
modprobe: FATAL: Module tun not found in directory /lib/modules/…
This error meansy you are missing the tun.ko.xz or tun.ko.gz in your kernel modules. This can be because your current kernel is not compatible with the current version of the TUN/TAP device driver. This would generally only ever occur in Linux distros with Rolling Release models. It should never happen on a stable or long-term distro such as Ubuntu, Debian, CentOS, or RHEL.
If you received that error in a stable distro, then check if the header is there first:
find /lib/modules -iname tun\.* # /lib/modules/5.6.13-arch1-1/build/include/config/tun.h # /lib/modules/5.6.13-arch1-1/kernel/drivers/net/tun.ko.xz
If you see only one of the above lines when you run that command, tun was BUILT but not LOADED, try rebooting.
You can try removing any network related kernel packages you’ve installed.
Check for any added kernel modules that didn’t load.
dkms status
for any
Try simply updating or upgrading your system.
If you receive an error when you run sudo modprobe tun:,
modprobe: FATAL: Module tun not found in directory /lib/modules/5.6.11-arch1-1
Always reboot after installing or updating kernel modules, or the Linux kernel itself.
After rebooting (if you failed the above command) you can see if it’s installed now:
find /lib/modules | grep tun\.ko\..z | xargs sudo insmod # insmod: ERROR: could not insert module /lib/modules/5.6.13-arch1-1/kernel/drivers/net/tun.ko.xz: File exists
That mean’s it’s installed and loaded.
sudo modprobe tun
Leave a comment if you need help, I usually respond within the day 🙂
Hi, I am using a Firefly ROC-RK3328-CC Single Board Computer with the Chinese manufacturer’s ubuntu 18.04 installed. I have done all updates/upgrades and mostly it is working (I seem to have some touchpad packages not being upgraded due to dependency issues… but I don’t need them). However, I am wanting to run this as an OpenVPN client and I have the ‘FATAL’ error “modprobe: FATAL: Module tun not found in directory /lib/modules/…” and then I “find /lib/modules -iname tun.*” without any results. Are you able to help me find how to install this driver?