Connect with us

Hi, what are you looking for?


How to setup a VPN on Linux in 5 minutes for free

How to setup a VPN on Linux in 5 minutes for free


by CodeDraken

In this short and late tutorial, we’ll create a Virtual Private Network (VPN) to help protect your anonymity on the Internet. I won’t talk much about what a VPN is or what these settings are. We’ll prepare one. Let’s get to it directly.

Windows version:

How to setup a VPN on Windows for free in 5 minutes
In this tutorial, we will create a VPN and bypass DNS to protect our

to update:

This works on Ubuntu <= 16.xx and most other distributions. If you are using Ubuntu 18+, see this post for updated steps.

If you have any issues, run a test on to see what exactly the information leak is, then view this response and the associated response. If this does not solve your problem, post a comment with as much information as possible.

You will need:

  • A computer running Linux OS. I am using Ubuntu. The commands may be different if you are not using a Debian-based distro.
  • Administration privileges / sudo
  • Basic computer skills
  • Basic knowledge of what a VPN is

Make a note of everything you change and make backups in case something goes wrong. Also, for the record, I am not affiliated with any of the sites linked here. Follow this tutorial at your own risk as you can mess around with some settings.

Part 1: Change your DNS

The Domain Name Server (DNS) can reveal some information about you, so we’ll want to change that. Start with a tool like DNS Leak Test to see what information is visible. Then work to hide it.

  1. We will be using OpenDNS. Head over to their website and get the nameserver IP addresses which can be found on their setup guide page

2. Edit: /etc/dhcp/dhclient.conf

Type or copy and paste the command into the terminal below. Nano is a text editor in the terminal. If the file is located somewhere else on your device google or search for it.

sudo nano /etc/dhcp/dhclient.conf

Look for the line that says “Before Domain Name Servers”. If the comment is made with # at the beginning of the line, uncomment by removing the #. Now change the line to use IP addresses from OpenDNS, and add more like mine below. Your internet may stop working temporarily at this point!

Previous Domain Name Servers,,;

This line means it will use the first address, then the second if the first address fails, and finally if the first two fail. This usually won’t happen we add because by default it uses 3 addresses. If we don’t add the third number and the first two fail, your real address will be used. Now save and exit as shown below:

Press CTRL + O
press enter
Press CTRL + X

This will save and close the file. Now we will need to restart the network manager with the following command.

restart sudo service network manager

You should now check to see if it works. Enter the command below, and check if the name servers appear or not. Run a DNS leak test on the website linked above.

cat /etc/resolv.conf

Possible problems

I did the steps, but the cat command only shows the nameserver
Thanks to Dietmar and Analyze Traders for this problem/solution
Try commenting/removing dns = dnsmasq From /etc/NetworkManager/NetworkManager.conf

Part 2: Setting up a VPN

Fix DNS Leak in Web Browser:

  1. in a fire fox Type about:config in the address bar and hit Enter.
  2. On the configuration page, find: media.peerconnection.enabled
  3. Change it to false by double clicking on it.
  4. Restart Firefox.

I don’t know how this is done in other browsers.

Get a free VPN

  1. Google for a free VPN, and make sure it’s good. I will be using VPNBook for the rest of the steps.
  2. On VPNBook, simply download the configuration file for the VPN you want. Copy the username and password. The password changes periodically, so you’ll need to get it again later. It doesn’t matter where you are when choosing your configuration file. You can be in the US, take down the Euro one, and look like you’re from Europe.

3. After extracting the downloaded zip file, open the terminal again. Change to the directory you extracted it from, or right-click and choose “Open in Terminal”. We have a few more steps now.

4. Install OpenVPN to use the configuration file.

sudo apt-get install openvpn

5. Close your browser and anything connected to the Internet. To use OpenVPN, enter the command below to run the configuration you want. Once you say “Initialization complete,” you’re all set. You must keep the station open. If it fails, try a different VPN, or read the error and try to figure it out.

sudo openvpn vpnbook-ca1-tcp443.ovpn

6. Finally, test if it works by doing another DNS leak test.

Congratulations if you made it this far and it works! Here is an additional simple bash script that you can run. You just need to change the password when needed.

bash text 1
Thanks to Adnan Rahish

#! / bin / bashcd /path/to/”vpnbook”password=”he2qv5h”read -sp “Enter sudo password:” sudopassword / usr / bin / sign << EOFspawn sudo openvpn vpnbook- eur1 -tcp443.ovpnexpect '$USER password:' send '$sudopasswordr' sign' enter 'Auth username:' send '$usernamer' sign' 'enter auth password:' send '$passwordr' sign' $ "EOF

This will start the VPN without having to enter your username and password manually. The VPN will still work in the background as well. Here’s a script to kill him if the need arises.

#! / bin / bashsudo pkill vpn

bash text 2

#! /bin/bashecho “user: vpnbook” echo “pass: 5VHZEps” sudo openvpn vpnbook-ca1-tcp443.ovpn

Just put that into a new file, right click > Properties > Permissions, and allow the file to be executed as a program. This example uses the Canada tcp 443 configuration.

in-depth reading

Here are some great articles by Quincy Larson that talk about VPNs, Internet privacy and security.

How to set up a VPN in 10 minutes for free (and why you need one so urgently)
“The computer allows you to make more mistakes faster than any other invention with the possible exceptions of pistols and…medium.freecodecamp.comHow to encrypt your entire life in less than an hour
“Only the paranoid survive.” – Andy

If you are interested in ethical hacking and security, there is a free 15-hour YouTube course.

Don’t forget to share this post with friends !

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *



AnyConnect: Install a self-signed certificate as a trusted source 👨‍💻 kmgmt-2879-cbs-220-config-security-port objective The goal of this article is to walk you through creating and...


ITProPortal . Portal 👨‍💻 We live in a dynamic moment in terms of technology. Even criminals are becoming more technically savvy and are using...


Top 5 Free AV Packages – 👌 Bitdefender Antivirus Free Edition best interface Positives Works on Windows 7 and 8.1 Very easy to use...


Download antivirus for free. Best antivirus protection 👨‍💻 Protecting your identity, banking information and privacy Cybercriminals want your credit card details, passwords and other...