Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian/Ubuntu - Start OpenVPN Connection

I have quite a few posts on how to configure an OpenVPN server, but once you have one set up and have been provided all the certificate/configuration files, one needs to know how to launch a connection to the server with it. Here's how (on Ubuntu/Debian):

Steps

Install OpenVPN if you haven't already.

sudo apt-get install openvpn -y

Navigate to where your client configuration file is, and start the VPN connection by referencing it.

cd /path/to/client.conf/directory

sudo openvpn \
  --config client.conf \
  --up /etc/openvpn/update-resolv-conf \
  --down /etc/openvpn/update-resolv-conf \
  --script-security 2

The calls to /etc/openvpn/update-resolv-conf ensure that your DNS updates when you connect/disconnect from the VPN connections, so that you can make use of the connections internal DNS (if it exists). If you don't wish to take on the VPN's DNS suggestions, then remove those parts.

References

Last updated: 5th September 2024
First published: 7th May 2022

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch