linux

Fixing the configuration of a TurnKey OpenVPN container on Proxmox

1 min read

When using the TurnKey template on Proxmox to create an OpenVPN server, after setting it up following the container installation steps, we may run into an error where VPN clients cannot connect. To look into the errors in more detail, we can edit the OpenVPN server configuration file in /etc/openvpn/server.conf and add the lines:

bash
log         /var/log/openvpn/openvpn.log
log-append  /var/log/openvpn/openvpn.log

And if we need more detail, we also change to

bash
verb  5

Restart the OpenVPN server

bash
systemctl restart openvpn

We can check the errors in the log file created in /var/log/openvpn, with the name set in the configuration, which in my case is openvpn.log. In it we will find an error saying the tun interface could not be created. This message appears because the container is not allowed to create certain devices, since it is configured to run in “unprivileged” mode. To get around this, do the following: Shut down the container. On Proxmox, add the following to the container’s configuration file in /etc/pve/lxc, named XXX.conf (where XXX is the container number, for example 102.conf):

bash
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file

Then we can start the container again and try our VPN connection. If we check the logs, the error message is gone.

#containers#proxmox#vpn