How to create TUN/TAP devices for LXC in ProxmoxVE 4.1

Flattr this!

LXC Container

First stop your container via webinterface or CLI. replace with your ContainerID whenever i write $CTID

root@proxmox:~# pct shutdown $CTID

and create a file autodev in the config directory of your LXC Container in /var/lib/lxc/$CTID

root@proxmox:/var/lib/lxc/$CTID# cat autodev 
#!/bin/bash

cd ${LXC_ROOTFS_MOUNT}/dev
mkdir net
mknod net/tun c 10 200
chmod 0666 net/tun 

root@proxmox:/var/lib/lxc/$CTID# ls
autodev  config  rootfs

Append two lines in /etc/pve/lxc/$CTID.conf

lxc.cgroup.devices.allow: c 10:200 rwm
lxc.hook.autodev: /var/lib/lxc/$CTID/autodev

This should be enough.

Start your container via CLI or WebInterface

root@proxmox:~# pct start $CTID

When you start your openVPN you should see in ifconfig your tun device:

root@container:~# ifconfig | grep tun
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

This was tested with Proxmox VE 4.1 – pve-manager/4.1-13/cfb599fb

Comments are closed.