4

When using starting OpenVPN as a service it does not use my /etc/openvpn/server.conf. When looking in the /var/log/syslog, I only see Started OpenVPN service. without any additional logging of OpenVPN.

When I start OpenVPN manually, openvpn --config /etc/openvpn/server.conf, I get a bunch of logging of OpenVPN and clients can connect with it.

How do I make sure that when starting it as a service, it uses the config file?

Debian GNU/Linux 9 OpenVPN 2.4.0 x86_64-pc-linux-gnu

3
  • 1
    What command are you using, service or systemctl? Try systemctl start [email protected] since you're on Debian 9.
    – Q23
    Commented Aug 14, 2017 at 20:54
  • I was using just service start openvpn, however the command you provided works! If you add it as an answer I can accept it. :)
    – joell
    Commented Aug 15, 2017 at 7:58
  • Got it covered. Took me a while to get used to systemctl, so I ended up having this problem often.
    – Q23
    Commented Aug 15, 2017 at 23:58

3 Answers 3

8

If you're using a systemd based OS like Ubuntu 16.04 or Debian 9, you'll need to use the systemctl command instead of service:

To enable at boot time:

systemctl enable [email protected]

To start and stop manually:

systemctl start [email protected]

systemctl stop [email protected]

You can enable, disable, start, and stop any OpenVPN configuration this way by replacing server with the name of the .conf file in /etc/openvpn.

2
  • 1
    Thanks for this answer – I had to search a lot until I found that. Weird that service works though and starts OpenVPN, but it just doesn't do anything useful apparently?
    – slhck
    Commented Jun 18, 2018 at 14:18
  • Brilliant! I tried a lot of things from other threads and nothing worked until I tried it this way! Thanks!
    – yuranos
    Commented Oct 5, 2018 at 13:59
0

If you're running systemd, changing files like /etc/default/openvpn and /etc/init.d/openvpn not enough, will require running systemctl on/off at the boot time:

systemctl enable openvpn.service

systemctl disable openvpn.service

In any case you can manually start/stop the client:

systemctl start openvpn.service

systemctl stop openvpn.service

See status with:

systemctl status openvpn.service
1
  • I don't see how this answers the question. Apparently, the OP is getting OpenVPN to start. Commented Dec 7, 2018 at 8:21
0

I had this exact issue happen as well on Debian 11, and found a lot of failure chatter in the syslog. I knew the service was working as intended, and it turned out that the service was enabled for both systemd and serviceV. The most confusing part is that these errors are logged as systemd even when using systemv.

In Debian the SysV service looks for /etc/openvpn/server.conf, whereas systemd will use a service openvpn-server@ where its files are in /etc/openvpn/server. Since @kirill-z already showed how to enable with SysV, I'm showing how to disable the SysV setup and use Debian's often preferred systemd setup

Disable OpenVPN with SystemV

I wanted to use was the Debian default (/etc/openvpn/server/server.conf), so seeing the logs trying to access /etc/openvpn/server.conf was the first indication. After checking the active services through service, I found openvpn was accidentally enabled.

# service --status-all

...
[ + ]  openvpn
...

You can then stop with:

# service openvpn stop

It's also possible openvpn has been setup to startup with systemV, in which case you'll want to disable it:

# update-rc.d openvpn disable

Then in the defaults make sure autostart is disabled.

# /etc/default/openvpn

...
#AUTOSTART="all"
AUTOSTART="none" // Uncomment this line
...

Now the systemV setup is completely disabled, and will not boot with SystemV on startup.

OpenVPN in SystemD

Start the systemd setup to verify the config. The following command will load the config /etc/openvpn/server/myserver.conf (change the @name to whatever your server config file name is).

# systemctl start openvpn-server@myserver

If all is good, we can set it to automatically startup on boot:

# systemctl enable openvpn-server@myserver

I hope this helps someone else out, as Debian continues to offer both service systems.

You must log in to answer this question.

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