Blame
| 27d260 | Samuli Seppänen | 2025-02-27 12:13:05 | 1 | # Systemd |
| 2 | ||||
| 3 | # OpenVPN systemd use |
|||
| 4 | ||||
| 5 | This is only a *brief* summary of OpenVPN systemd usage. |
|||
| 6 | ||||
| 7 | OpenVPN **must** be compiled with systemd support. |
|||
| 8 | ||||
| 9 | Use the correct OpenVPN supported systemd `.service` files. |
|||
| 10 | ||||
| 11 | ### Build OpenVPN with systemd support |
|||
| 12 | ||||
| 13 | When you build the openvpn binary use the configure option `--enable-systemd` like so: |
|||
| 14 | ||||
| 15 | ``` |
|||
| 16 | ./configure --enable-systemd |
|||
| 17 | ``` |
|||
| 18 | ||||
| 19 | Verify OpenVPN systemd support has been enabled like so: |
|||
| 20 | ||||
| 21 | ``` |
|||
| 22 | $ openvpn --version |
|||
| 23 | ``` |
|||
| 24 | Look for `enable-systemd=yes` in the output. |
|||
| 25 | ||||
| 26 | ### Using OpenVPN with systemd support |
|||
| 27 | ||||
| 28 | In order to use OpenVPN with systemd please use the correct systemd `.service` file. |
|||
| 29 | ||||
| 30 | **Server**: |
|||
| 31 | ||||
| 32 | * Place your server configuration file in `/etc/openvpn/server` |
|||
| 33 | * Use the `openvpn-server@.service` like so: |
|||
| 34 | ||||
| 35 | ``` |
|||
| 36 | $ sudo systemctl start openvpn-server@{Server-config} |
|||
| 37 | ``` |
|||
| 38 | Replace `{Server-config}` with the `name` of your config file without the `.conf` |
|||
| 39 | **Client**: |
|||
| 40 | ||||
| 41 | * Place your client configuration file in `/etc/openvpn/client` (notice however that, due to an outdated version of openvpn, some distributions, like Ubuntu 20.10, look for configuration files under `/etc/openvpn` instead of `/etc/openvpn/client`. In case of doubt, check the specific error message in `journalctl -xe`) |
|||
| 42 | * The filename must end in `.conf`, so if your client config file is something like `profile.ovpn` rename it to `somename.conf` (where `somename` is meaningful to you, to describe where you are connecting.) |
|||
| 43 | * Use the `openvpn-client@.service` like so: |
|||
| 44 | ``` |
|||
| 45 | $ sudo systemctl start openvpn-client@{Client-config} |
|||
| 46 | ``` |
|||
| 47 | Replace `{Client-config}` with the `name` of your config file without the `.conf` |
|||
| 48 | ||||
| 49 | **Start at boot**: |
|||
| 50 | ||||
| 51 | Replace `start` with `enable` |
|||
| 52 | ||||
| 53 | Other systemd questions are probably best answered by reading `man systemctl` etc .. |
|||
| 54 | ||||
| 55 | **Note**: |
|||
| 56 | ||||
| 57 | * `openvpn@.service` is **deprecated**. |
|||
| 58 | * `openvpn.service` is **obsoleted**. (This is only used for backward compatibility) |
|||
| 59 | ||||
| 60 | ### Known issues |
|||
| 61 | ||||
| 62 | * https://community.openvpn.net/openvpn/ticket/945 |
|||
| 63 | * https://community.openvpn.net/openvpn/ticket/1089 |
