2
[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? :/

  • 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. – MariusMatutiae Dec 8 '17 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 Dec 8 '17 at 16:51
6

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 openvpn-client@.service and openvpn-server@.service template units have.

(openvpn@.service 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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.