How to Setup a VPN on Ubuntu in Easy Steps (Updated 2024)

How to Setup a VPN on Ubuntu in Easy Steps (Updated 2024)

A Virtual Private Network (VPN) is a useful tool for privacy and security on the internet. It allows you to discreetly connect to a public network through a bunch of secure servers. It redirects your traffic through an encrypted tunnel that hides your original IP address. You’ll need a VPN for accessing geo-restricted content, streaming videos, or protecting your data from hacking and monitoring.

Ubuntu is a top-class open-source platform. It is secure, but it isn’t immune to all the security threats that lurk on the internet. For added security, a VPN is necessary. Setting up a VPN for Ubuntu may have seemed complicated before, but we’ll show you some easy steps to follow.

How to Set Up a Ubuntu VPN

There are so many VPNs currently available on the market. They use different security protocols and may require separate installation processes. Also, you may need to check with your provider if you’ll need to download any extra files. Here are some easy steps to guide you:

Setting Up a VPN on Ubuntu (via Terminal)

For this example, we’ll use OpenVPN.

1. Create an account with a VPN service provider.

2. On Ubuntu, open the terminal (Ctrl+Alt+T)

3. Enter the following command: sudo apt-get install network-manager-OpenVPN.

4. Type ‘Y’ and press the Enter key.

5. Then you type in the following command:

sudo apt-get install network-manager-OpenVPN

sudo apt-get install network-manager-OpenVPN-gnome

6. After the installation is complete, download the OpenVPN file.

7. Disable and reenable networking to restart the network manager after the installation.

8. Extract the downloaded file.

9. Click on the network manager icon, and then click on ‘connection.’

10. Click on the dropdown menu to choose OpenVPN and then click on create.

11. Fill in the following required information:

12. Connection name

13. Required gateway/server

14. Password

15. Username and password provided by the VPN service

16. CA Certificate.

How to Connect a VPN Through Ubuntu Network Manager

An easier alternative for connecting VPN servers via terminal is the Ubuntu Network Manager. Use the following steps as a guide:

1. Get a certificate from your VPN provider. You can easily find them when you log on to the VPN’s website.

2. Once you’re logged in, scroll to VPN, select manual setup, and then choose manual.

3. Open the credentials tab. You should be able to find the necessary credentials.

4. Every server requires a configuration file. Click on the ‘files’ tab, and then choose your preferred server/location, and download the file.

5. Choose between UDP and TCP protocols.

6. On your system, go to the ‘activities’ section and then click on network.

7. Click on the plus sign at the bottom of the page to create a new VPN connection.

8. Select ‘VPN’ on the list.

9. Choose your VPN connection type.

10. Enter the necessary VPN details.

11. After configuring the VPN, click on the system menu to connect to a VPN server. When a secure connection has been established, there will be a lock icon in the top bar.

Other Commands

Some other commands:

Connecting to a Server

1. When you launch your VPN, there will be a list of servers. Every server location has a different number, so you will have to type in the number and then press Enter.

2. You can choose between UDP and TCP protocols, type the UDP/TCP number, and press Enter.

3. Once the connection is established, the VPN will display a new IP.

Disconnecting from a Server

1. Click on the system menu

2. Then click on ‘turn off’ under your VPN’s name.

Why You Should Use a VPN on Ubuntu

A VPN is a great asset to have on Ubuntu. Some of the reasons why you need to use a VPN on Ubuntu are:

1. To Protect your Data

Ubuntu has reliable security protocols, but it isn’t immune to hacks or data leaks. When you connect to a public or unsafe network, you are at risk of so many threats.

Hackers could easily monitor your activities and steal your sensitive information like financial and medical details. However, a VPN encrypts your traffic data when you’re online, so you are protected from eavesdropping, data leaks, phishing, and other cybercrimes.

2. To Maintain Your Privacy

Even though Ubuntu would not collect and share your information with a third party, the internet is full of many websites that collect personal data (sometimes without your permission).

Many people don’t realize that their Internet Service Provider (ISP) has access to their personal information online, including sensitive stuff.

In some cases, the government could retrieve such information from your ISP to keep tabs on your activities. Countries that are part of the Five Eyes, Nine Eyes, and Fourteen Eyes alliances are known to carry out surveillance on their citizens and share information actively.

For advertisers, details about what sites you visit, purchases made, and other digital footprints are gold. Advertisers try to monitor your internet activities through your IP address, to create targeted ads for you.

A good VPN maintains your privacy. Through encryption, your data stays private, and nobody can pry into your online activities.

When you are connected to a VPN server your online activity will be hidden.

3. For Your Online Freedom

If you live in countries like China, Russia, Ukraine, or Zimbabwe, you must have experienced internet censorship in one form or the other. For example, China has a nationwide firewall known as the Great Firewall of China. This firewall allows the government to regulate information accessible in China and control internet services that operate in the country.

Even in more liberal countries, you may still have to deal with other limitations like hate speech laws, which could be used as a pretext for further restrictions.

With all your information encrypted by a VPN, you have the freedom of your speech in your hands. A VPN exchanges your real IP address with another from a selected server. This gives you a new identity online.

4. Bypassing Geo-blocks

There’s so much interesting content online, but in some cases, geo-blocks prevent you from having access to them.

These geo-restrictions are set up to limit access to certain websites and content to specific geographical locations. For example, some TV shows and movies on streaming platforms like Hulu, Netflix, or HBO can only be enjoyed by people living in a particular country or region. Pretty annoying, right?

To access content or services restricted to a certain country, you have to connect to a server in that location, and you’re good to go. This is helpful if you’re on a trip abroad and discover you can’t keep up with your shows and other online services.

A VPN will help you access geoblocked content on streaming services such as Netflix.

5. Torrenting

Torrenting is quite popular on the internet. While it is okay to download torrents in some countries, it is against the law and could cause serious legal action in some others. So when you go online to download a movie, file, song, or videogame through a torrent, your ISP could flag it as illegal.

Your ISP can see your real IP address, so they are aware of all your internet activities. Also, when you use a torrent, the operator and other people that download the same torrent can easily know your IP address and all the personal details linked to it.

Torrenting with an Ubuntu VPN keeps you anonymous through encryption and rerouting your traffic data through multiple servers.

6. To Avoid Bandwidth Throttling

One interesting thing that ISPs do is bandwidth throttling, which means that your internet speed is intentionally slowed down. It happens when you’ve used up so much data in a short time.

ISPs do this often to reduce the chances of network congestion or sell data plans to their customers. Your ISP monitors your data consumption through your IP address.

With an Ubuntu VPN, your IP address is cloaked. And since your ISP won’t be able to see your real IP, they won’t be able to know how much data you’re consuming.


It is easy to set up a VPN for Ubuntu. Once you find the best VPN available for Ubuntu, all you have to do is carefully follow the guide we’ve provided. If you encounter any issues or have comments or questions, please contact your VPN provider.