You are not logged in.

#1 2018-10-29 20:46:42

equalizer876
Member
Registered: 2018-09-11
Posts: 78

systemd Unit for OpenVPN

Hello,

I thought a systemd service to autostart a VPN tunnel would be a great idea since openvpn requires root and I want to run it on an unprivileged user account. My systemd unit looks like:

[Unit]
Description=OpenVPN tunnel to <server>
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/var/run/openvpn-client/<server>.pid
ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn-client/<server>.pid --cd /etc/openvpn/client --config <server>.conf

[Install]
WantedBy=multi-user.target

VPN works with this, but when I suspend my computer (systemctl suspend) and wake it up again, then the daemon doesn't work anymore.
What I want to achieve? The process or the whole systemd Unit needs to be restarted automatically, when the daemon dies. How to do it?

Last edited by equalizer876 (2018-10-31 20:38:45)

Offline

#2 2018-10-29 20:56:21

jbenge1
Member
From: Az
Registered: 2018-04-09
Posts: 151

Re: systemd Unit for OpenVPN

https://bbs.archlinux.org/viewtopic.php?id=218234 is probably why?

What does the journal say about this?

Maybe try

Restart=on-failure

"Dr. Madden, why don't the natural numbers include 0?" -me
"....... Take a philosophy course" -Dr. Madden

Offline

#3 2018-10-29 22:25:00

equalizer876
Member
Registered: 2018-09-11
Posts: 78

Re: systemd Unit for OpenVPN

jbenge1 wrote:

Maybe try

Restart=on-failure

makes no difference

After resume "journalctl -xe" only reports this about openvpn:

openvpn[10753]: Recursive routing detected, drop tun packet to [AF_INET]x.x.x.x:<port>
openvpn[10753]: Recursive routing detected, drop tun packet to [AF_INET]x.x.x.x:<port>
openvpn[10753]: Recursive routing detected, drop tun packet to [AF_INET]x.x.x.x:<port>
openvpn[10753]: Recursive routing detected, drop tun packet to [AF_INET]x.x.x.x:<port>
openvpn[10753]: Recursive routing detected, drop tun packet to [AF_INET]x.x.x.x:<port>
...

(endless strings with the same message)

It only works again when I restart the computer or type command "systemctl restart <unit>".

Last edited by equalizer876 (2018-10-29 22:25:41)

Offline

#4 2018-10-29 22:46:09

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Offline

#5 2018-10-31 20:34:55

equalizer876
Member
Registered: 2018-09-11
Posts: 78

Re: systemd Unit for OpenVPN

Thanks for the link. This solved the problem after resume.

Another problem occurred: When I disable ethernet and activate it again, the problem from the first post repeats. So to cover most cases we need to restart the OpenVPN unit whenever the internet connection is lost. Which addition do I need to write into the resume unit?

Offline

Board footer

Powered by FluxBB