wiki:OpenVPN-systemd-use

Version 9 (modified by tct, 2 years ago) (diff)

--

OpenVPN systemd use

This is only a brief summary of OpenVPN systemd usage.

Details: https://github.com/OpenVPN/openvpn/blob/master/distro/systemd/README.systemd

OpenVPN must be compiled with systemd support.

Use the correct OpenVPN supported systemd .service files.

Build OpenVPN with systemd support:

When you build the openvpn binary use the configure option --enable-systemd like so:

./configure --enable-systemd

Verify OpenVPN systemd support has been enabled:

$ openvpn --version | grep systemd

Look for enable-systemd=yes in the output.

Using OpenVPN with systemd support:

In order to use OpenVPN with systemd please use the correct systemd .service file.

Server:

  • Place your server configuration file in /etc/openvpn/server
  • Use the openvpn-server@.service like so:
    $ sudo systemctl start openvpn-server@{Server-config}
    
    Replace {Server-config} with the name of your config file without the .conf

Client:

  • Place your client configuration file in /etc/openvpn/client
  • Use the openvpn-client@.service like so:
    $ sudo systemctl start openvpn-client@{Client-config}
    
    Replace {Client-config} with the name of your config file without the .conf

Start at boot:

Replace systemctl start ... with systemctl enable ...

Interrogate systemd

Use systemctl to show your current systemd-daemon state.

Other systemd questions are probably best answered by reading man systemd

Note:

  • openvpn@.service is deprecated.
  • openvpn.service is obsoleted. (This is only used for backward compatibility)

Known issues:

https://community.openvpn.net/openvpn/ticket/945
https://community.openvpn.net/openvpn/ticket/1089