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.