Post

Systemd example

NOTE: All configurations were taken from a lab environment.

Here an example of how to make OpenVPN iniate as a Service using Systemd.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
root@openvpn-server:~# cat /etc/systemd/system/openvpn.service
[Unit]
Description=openvpn
Wants=network-online.target test-internet.service
After=network-online.target test-internet.service

[Service]
User=root
SyslogIdentifier=openvpn
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/sbin/openvpn --config /home/root/openvpn-server.ovpn
Restart=always

[Install]
WantedBy=multi-user.target
root@openvpn-server:~# 

Enable the service

1
2
3
4
5
6
7
root@openvpn-server:~# systemctl status openvpn

root@openvpn-server:~# systemctl start openvpn

root@openvpn-server:~# systemctl status openvpn

root@openvpn-server:~# systemctl enable openvpn
This post is licensed under CC BY 4.0 by the author.