I would like to connect OpenVPN on Startup.
I've added sudo openvpn /file.ovpn
to the crontab
, and it doesn't connect at startup.
What is the proper procedure?
linuxlinux-networkingopenvpnUbuntuvpn
I would like to connect OpenVPN on Startup.
I've added sudo openvpn /file.ovpn
to the crontab
, and it doesn't connect at startup.
What is the proper procedure?
Best Answer
As an admin you typically use cron to schedule recurring jobs, not to run daemons and services that need to start boot.
Additionally, when you have admin rights, you don't use
sudo
in cron jobs, you set the correct user in the<user>
field of the/etc/crontab
or the/etc/cron.d/job.spec
configuration file.Read the manual: https://openvpn.net/index.php/open-source/documentation/howto.html#startup
So it may already be sufficient to simply copy your config file to
/etc/openvpn/connection-name.conf
I recently had to set up OpenVPN on an Ubuntu 16.04 LTS server and the process was slightly more complicated, since with systemd the init script isn't used any more but instead a templated systemd unit file is used.
/etc/openvpn/connection-name.conf
systemctl start openvpn@connection-name
ip addr list
andip route list
systemctl status openvpn@connection-name
and/orjournalctl --identifier ovpn-connection-name
and/orsystemctl enable openvpn@connection-name