3
[Unit]
Description=Simple Openvpn tunnel

[Service]
Type=simple
ExecStart=/usr/sbin/openvpn --config /etc/vpn/config/myclient.ovpn --daemon

[Install]
WantedBy=multi-user.target

I have this service, I can also enable it but starting is not working. status is giving me this:

● openvpn.service - Simple Openvpn tunnel
   Loaded: loaded (/etc/systemd/system/openvpn.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2017-12-08 09:24:32 CET; 3s ago
  Process: 29772 ExecStart=/usr/sbin/openvpn --config /etc/vpn/config/client-0-130.ovpn --daemon (code=exited, status=1/FAILURE)
 Main PID: 29772 (code=exited, status=1/FAILURE)

Dec 08 09:24:32 s20699657 systemd[1]: Started Simple Openvpn tunnel.
Dec 08 09:24:32 s20699657 systemd[1]: openvpn.service: Main process exited, code=exited, status=1/FAILURE
Dec 08 09:24:32 s20699657 systemd[1]: openvpn.service: Unit entered failed state.
Dec 08 09:24:32 s20699657 systemd[1]: openvpn.service: Failed with result 'exit-code'.

I can't find out what is missing. can someone please look at it? :/

2
  • By far the easiest thing is to start openvpn by executing the start command, openvpn --config /etc/vpn/config/myclient.ovpn (without the daemon option) from the CLI, and study the error message you get. Otherwise dmesg or syslog might hold some info. Commented Dec 8, 2017 at 8:49
  • @MariusMatutiae in cli it works without problem I think the issue is with the /usr/sbin/openvpn. in cli, I just do openvpn --config /etc/vpn/config/myclient.ovpn and it works
    – doniyor
    Commented Dec 8, 2017 at 16:51

1 Answer 1

11

Use the Debian-supplied mechanism

Don't roll your own service units. Debian comes with a mechanism for scanning your OpenVPN configuration and making systemd services to match it. Use that.

Make a *.conf file in /etc/openvpn. Debian's/Ubuntu's /lib/systemd/system-generators/openvpn-generator will make the service units to match.

Note that newer versions of OpenVPN have split the configuration files directory into /etc/openvpn/client and /etc/openvpn/server. This has not (yet) percolated down into a stable version of Debian, although the OpenVPN-supplied [email protected] and [email protected] template units have.

([email protected] is a Debian-supplied service unit that works with the Debian-supplied generator. These are local Debian-made modifications to OpenVPN. The OpenVPN-supplied service unit templates were developed independently by the OpenVPN people themselves. They are also better. If you really want to not use the Debian mechanism, using these should be your next stop, before rolling your own service units.)

Further reading

1
  • i dont want to start openvpn server, I just need to start the client as daemon. For this I need debian-supplied mechanism?
    – doniyor
    Commented Dec 8, 2017 at 16:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .