[SOLVED] OpenVPN Tun\Tap device - Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)

is-max

New Member
Jan 29, 2015
15
1
3
Hi,

We use LXC (and had used OpenVZ) mainly for openvpn, I got a problem wich a lot of people are encontering with LXC, the error message:
Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)

Today I had and hard day, with the Ubuntu 12.04 and debian 8 template for LXC,
because OpenVPN refuses to start during the boot, despite the device was there, when you log-in.

After an entire day, I found the problem and a solution.

The problem:
OpenVPN SysV Startup script is called before the Upstart /etc/init/mounted-dev.conf .

The solution I had to use was to write a configuration file in:
File: /usr/share/lxc/config/common.conf.d/02-openvpn-auto-tun.conf
Code:
lxc.hook.autodev = /usr/share/lxc/hooks/openvpn-auto-tun

Then copy the script I've found on Archlinux website in:
File: /usr/share/lxc/hooks/openvpn-auto-tun
Code:
#!/bin/bash
cd ${LXC_ROOTFS_MOUNT}/dev
mkdir net
mknod net/tun c 10 200
chmod 0666 net/tun

Set the right permission to the script file:
Code:
chmod 755 /usr/share/lxc/hooks/openvpn-auto-tun

Then, stop\shutdown (don't reboot) and start again the LXC Container, and it will magically work.

I hope, that it will be usefull for someone else, who will arrive here for the same problem.

Regards

-- For future reference the used version of ProxMox is 4.1-1/2f9650d4 --
 
  • Like
Reactions: t.lamprecht

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!