ProxMox 4 : autoriser OpenVPN (tun) dans un CT LXC

lxc 26 janv. 2017

Installer OpenVPN dans un container LXC sur ProxMox 4.x nécessite de modifier le fichier de configuration du CT et le CT lui-même. En effet le dit CT doit pouvoir créer une interface virtuelle TUN.

Pour installer OpenVPN sur le CT 150, il faut éditer le fichier /etc/pve/lxc/150.conf pour lui ajouter ceci (merci ArchWiki)

lxc.cgroup.devices.allow = c 10:200 rwm

Ce qui donnera une configuration de ce genre

arch: amd64
cores: 1
hostname: VPNPlex2
memory: 512
nameserver: xxx yyy
net0: name=eth0,bridge=vmbr0,gw=zzz,hwaddr=xxx,ip=xxx/24,type=veth
ostype: debian
rootfs: local:111/vm-111-disk-1.raw,size=8G
searchdomain: xxx
swap: 512
lxc.cgroup.devices.allow = c 10:200 rwm

On peut maintenant démarrer le CT puis modifier son fichier /etc/rc.local comme ceci (le code entre # … does nothing et exit 0)

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

if ! [ -d /dev/net ];then
mkdir /dev/net
fi
if ! [ -c /dev/net/tun ]; then
mknod /dev/net/tun c 10 200
chmod 666 /dev/net/tun
fi

exit 0

Pour terminer, arrêter/démarrer le CT depuis ProxMox (Manager ou CLI) afin que le script soit pris en compte au boot. Et c’est tout, nous avons alors bien “tun”

root@VPNPlex2:/dev/net# ls
tun

 

 

Mots clés