I'm using Ubuntu 12.04 64bit. I have an *.ovpn
file that works if I type:
sudo openvpn client.ovpn
Now I would like to start up openvpn
when I boot the computer.
How can I do this?
I'm using Ubuntu 12.04 64bit. I have an *.ovpn
file that works if I type:
sudo openvpn client.ovpn
Now I would like to start up openvpn
when I boot the computer.
How can I do this?
Download the
OpenVPNConfigFile.ovpn
. Note that you can rename the file to anything you like.Move the ovpn file to
/etc/openvpn
cd /etc/openvpn
folder and entersudo nano yourserver.txt
Save and Close
sudo nano OpenVPNConfigFile.ovpn
Find
auth-user-pass
and addyourserver.txt
next to it so that it becomesThis will allow you to skip entering your credentials everytime you start openvpn connection
Rename
OpenVPNConfigFile.ovpn
toOpenVPNConfigFile.conf
sudo nano /etc/default/openvpn
Uncomment
AUTOSTART="all"
sudo service openvpn start
You should see a message saying that you are connected. The connection will be established every time you start your computer.
The
openvpn
package comes with an init script/etc/init.d/openvpn
. This script automatically sets up connection for every.conf
(mind the extension) file in/etc/openvpn
.Found this based on information here: https://openvpn.net/index.php/open-source/documentation/howto.html#startup
It would be nice to have a un hacker way of doing it, but this will have to do for now.
Create file myopenvpn in
/etc/init.d/
Insert into myopenvpn and save:
SOURCE: How to auto start OpenVPN client in Debian 6 and Ubuntu 12.04
I got a bit stuck on this and ended up writing out all of the instructions for setting it up with systemd manually.
This worked for me using Ubuntu 16.10 and openvpn 2.3.11
Setting up your vpn to run from bash
These examples use expressvpn but most would work the same way
Download your vpn provider's ovpn config file e.g. my_express_vpn_amsterdam_2.ovpn
move that to
/etc/openvpn/
and rename it to end in .confYour VPN provider will provide you with a username and password for connecting over openvpn. Save the userename and then password each on their own line
now edit
/etc/openvpn/amsterdam-2.conf
look for a line that saysauth-user-pass
and replace it with the path to your credential fileTest your config! Start openvpn like this
openvpn should connect without asking for username or password
Remove existing (broken) service config for openvpn
Set up openvpn to run as a systemd service
The config that came with openvpn was broken so I removed it and created a new one based on this answer
Create systemd service for openvpn
add this config:
the
%i
is used as a wildcard so that this service can be used for multiple vpn configurations. Set it up for theamsterdam-2.conf
file that we created earlierthe systemd service should now be running on the amsterdam vpn. check its status like so
you should see several lines of output ending in
Initialization Sequence Completed
and your vpn should be running.Hope this helps! related reading: