0

I try to start openvpn at boot on a machine running Xubuntu 18.04. I put my credentials of the service I use in a separate file and put the name of that file in the OVPN file as described in: https://askubuntu.com/questions/464264/starting-openvpn-client-automatically-at-boot#464269. When I type: sudo openvpn /etc/openvpn/name.ovpn, openvpn does not ask for my credentials and starts with no errors.

So that is okay. However, I tried every trick as mentioned in the url mentioned earlier but I can not make openvpn build the connection at bootup. Netually I reboot the machine after every change.

Then I tried to add the service to cron with sudo crontab -e. @reboot openvpn /etc/openvpn/name.ovpn The changed crontab is installed. After reboot the machine I am still not protected. ifconfig confirms there is no VPN tunnel set up. According to syslog, openvpn does start without errors. The cron log nor the openvpn log show errors.

I also read many other information on the internet but without any other real solution.

I am at a loss here. Can anyone help?

Thank you in advance.

kostix
  • 1,160
Erik
  • 3

2 Answers2

2

According to your comment, this line

/lib/systemd/system/openvpn@.service; disabled; vendor preset: enabled

seems to indicate that the service is disabled.

You can try to do in sequence

sudo systemctl daemon-reload
sudo systemctl enable openvpn@client

and then reboot.

EDIT as per request

sudo systemctl daemon-reload refreshes the systemd system (re-reads configurations files, regenerates structures, etc.). The manpage says:

daemon-reload
   Reload systemd manager configuration. This will rerun all generators (see systemd.generator(7)), reload
   all unit files, and recreate the entire dependency tree. While the daemon is being reloaded, all sockets
   systemd listens on behalf of user configuration will stay accessible

I personally never understood when it should be used, but often resolved startup problems for me ;)

sudo systemctl enable openvpn@client simply tells the systemd system to enable the specified service, i.e. starting up at the appropriate time and stopping when it should. In the case of openvpn it probably starts after the networking is setup an it stops when shutting down the system.

1

This answer helped me, I was floundering around simply doing a systemctl enable openvpn, I needed to do systemctl enable openvpn@client The next problem was easily found by looking at journalctl -xe I then found the major problem was the name of my config file. Instead of client.ovpn I changed to client.conf and all worked.

Ian Ward
  • 11
  • 1