30

I cannot manage to load the tun module in my ArchLinux box. I’m trying to connect with OpenVPN, but the log says:

nm-openvpn[6662]: Note: Cannot open TUN/TAP dev /dev/net/tun: No such device (errno=19)

lsmod | grep tun

Returns nothing:

If I run:

sudo modprobe tun

It returns failure, but no error message, and lsmod still has no tun. The module seems to exist, as there is a tun.ko.gz in /lib/modules/.

I really dont know what else to try.

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
rabipelais
  • 411
  • 1
  • 4
  • 7
  • 1
    Very often this problem is caused by upgrading a kernel version without rebooting the machine. Just reboot and `modprobe tun` should work. See @Sponge5 answer for details – John Smith Dec 19 '22 at 10:55

6 Answers6

32

This answer is probably a bit late, but I ran into the problem, exactly as described, myself.

Running OpenVPN would produce:

Note: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)

And running tunctl would produce:

Failed to open '/dev/net/tun' : No such file or directory

And this command had no output:

lsmod | grep tun

When attempting to add the tun module via:

modprobe tun

modprobe would exit with a failure error code (1), and nothing changed.

I found an alternate way of activating the tun module via insmod. First locate the module with this command:

find /lib/modules/ -iname 'tun.ko.gz'

Then use insmod with the returned path (I only got one match), for example:

insmod /lib/modules/3.6.9-1-ARCH/kernel/drivers/net/tun.ko.gz

For me, running that command worked, and tunctl and OpenVPN worked okay afterwards.

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
Alex Szczuczko
  • 436
  • 4
  • 4
27

I ran into a similar problem when trying to run openvpn on OVH Cloud VPS, openvpn complains that cannot find TUN interface.

modprobe will always return module not found :

$ sudo modprobe tun
FATAL: Module tun not found.

Finally, I found that tun is not a module but built in kernel, so what I do to solve was created the missing dir and nod:

$ sudo mkdir /dev/net
$ sudo mknod /dev/net/tun c 10 200

And then openvpn can find and use the tun device.

To be noted that afterward, modprobe will still return an error, because tun is not a module.

$ sudo modprobe tun
FATAL: Module tun not found.
Cyril
  • 371
  • 3
  • 3
  • Thanks, I got this problem with OpenVPN Access Server on OVH Classic VPS after doing a dist-upgrade from Debian 7 to Debian 8. You can also do `sudo chmod 600 /dev/net/tun` like said in this article: http://wiki.vpslink.com/TUN/TAP_device_with_OpenVPN_or_Hamachi After restarting openvpn with `sudo service openvpnas restart`, I could connect with a client. But when I restart the Linux server, /dev/net/tun does not exist anymore. I don't know if it's normal but I added commands to /etc/rc.local so it will still work after reboot. – baptx Jun 28 '15 at 16:34
  • Thanks. Your solution worked for my armbi port of debian squeeze running on my android mobile. I got the same error while starting OpenVPN. – Sourav Ghosh May 12 '17 at 21:13
  • yes, `tun` is not a module. – MrRolling Jan 24 '18 at 04:00
  • thas works for me thanx. – Pouya Samie May 12 '18 at 19:36
4

In Arch linux installing the networkmanager-vpnc or NetworkManager-vpnc package will solve the problem

MrRolling
  • 149
  • 4
3

Make sure you do a kernelcheck before running modprobe. See note here

An easy way is to compare the output of

uname -r

and

pacman -Q linux

If they're different, reboot. That should fix the modprobe failure.

Sponge5
  • 31
  • 1
  • Thank you! I'm using Manjaro and I haven't resbooted my machine since the last kernel upgrade. A simple reboot solved the problem. – Botond Balázs Jan 27 '21 at 13:49
0

I had a problem where my /lib/modules/.../modules.alias did not contain the line

alias char-major-10-200 tunode_tunnel

So even if you've done mknod /dev/net/tun and have tun.ko somewhere in /lib/modules/..., it won't load unless modules.alias has the right incantation.

ceilingcat
  • 101
  • 1
0

The simplest solution would be rebooting you system and then doing modprobe tun as root, because the most likely cause of the failed modprobe call is a kernel version mismatch with a module version (for me that was the case).

You see, after updating the system (assuming the kernel is also updated), you continue to use the old kernel, but the modules are installed from a new kernel version. That's why you can't do modprobe right after the upgrade.

fogjet
  • 1
  • Welcome to SuperUser! How is this answer better than the accepted one from over 10 years ago? – DarkDiamond Aug 29 '22 at 10:34
  • Given that the reason why modprobe does not work is the mismatch between the module version and the kernel version, then such an insmod is potentially dangerous. My problem with modprobe was solved by a simple system reboot - no risky trickery required. I tried to put this note under commets to the accepted answer, but this wonderful platform says I don't have enough reputation. – fogjet Aug 30 '22 at 11:33