I know that systemd does not recommend using /etc/init.d for start on boot, but should I write the “start command” from above directly in /etc/systemd/system then?
Sorry, I’m not very skilled in programming… Do you mean that I create the etc/openvpn/NL.conf into the etc/openvpn folder, and then put the following commands into it ?
OK. So you want me to rename the NL.ovpn into NL.conf, place it under the directory /etc/openvpn and modify the content of the /etc/default/openvpn to “AUTOSTART the NL.conf”. Correct ?
I get the following data when enabling the openvpn, is that normal ?
Synchronizing state for openvpn.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d openvpn defaults
insserv: warning: script 'K01startSB.sh' missing LSB tags and overrides
insserv: warning: script 'startSB.sh' missing LSB tags and overrides
Executing /usr/sbin/update-rc.d openvpn enable
insserv: warning: script 'K01startSB.sh' missing LSB tags and overrides
insserv: warning: script 'startSB.sh' missing LSB tags and overrides
Thank you for the instructions! After using them I was able to start and stop openvpn using systemctl, but after reboot it didn’t automatically start despite I enabled it.
To make this work I added to /lib/systemd/system/openvpn@.service into section [Unit] two lines:
Wants=network-online.target
After=network-online.target
My configuration:
In my experience those two lines have not been necessary. OpenVPN will keep trying until it gets a connection, even if it starts before the network is up. It already contains the line After=network.target.
You should also remember that the change will probably be overwritten when there is an update to OpenVPN.
I am reviving this thread as I have just changed my VPN provider to CyberGhost and installed the ovpn and .conf files as needed. It starts on boot, starts manually, but for whatever reason it drops after some minutes and does not restart on its own.
Any idea what I should check ?
I do have the AUTOSTART command in the /etc/default/openvpn file)
and I even added Restart=on-failure in the /lib/systemd/system/openvpn@.service file under [Service] section
EDIT: after a false hope it dropped again. Looks like it is dropping after some random time (and yesterday was rather after a longer time, hence my hope)
I checked the status of this tunnel, after a crash or while running, through systemctl status openvpn@cyber_LT, and here the result https://paste.osmc.tv/tafoxomagu.rb....if that helps.
yes, I did setup the watchdog, this is why I was happy it worked, but unfortunately, it might have been only due to the longer period without dropping. I’ll contact them.