Enabling OpenVPN with systemctl

From lxadm | Linux administration tips, tutorials, HOWTOs and articles
Jump to: navigation, search

If your distribution just switched to systemctl (i.e. Ubuntu 16.04) you may notice that your custom OpenVPN configs placed in /etc/openvpn/*.conf no longer start. Also, it gives no clues in the log on why it wouldn't start.

This is because they are managed by systemctl now and have to be enabled separately.

For example, if your OpenVPN config file is /etc/openvpn/some-config.conf - it has to be enabled as follows:

  • query current status (below - disabled):
# systemctl status openvpn@some-config
● openvpn@some-config.service - OpenVPN connection to some-config
   Loaded: loaded (/lib/systemd/system/openvpn@.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:openvpn(8)
           https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage
           https://community.openvpn.net/openvpn/wiki/HOWTO


  • enable "some-config" config for OpenVPN:
# systemctl enable openvpn@some-config
Created symlink from /etc/systemd/system/multi-user.target.wants/openvpn@some-config.service to /lib/systemd/system/openvpn@.service.
  • query the status again - you will see it's enabled, though not yet running (inactive):
# systemctl status openvpn@some-config
● openvpn@some-config.service - OpenVPN connection to some-config
   Loaded: loaded (/lib/systemd/system/openvpn@.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:openvpn(8)
           https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage
           https://community.openvpn.net/openvpn/wiki/HOWTO
  • finally, start it:
# systemctl start openvpn@some-config
  • confirm it's running:
# systemctl status openvpn@some-config


You will finally see it's present in the processlist (i.e. ps aux|grep openvpn), that it logs to syslog etc.