Virtual Private Networks (VPNs) are a mainstay of internet privacy, providing anonymity and the ability to conceal your location. With servers around the world, commercial VPN providers let you access geo-blocked content by pretending you’re in a country where that content is allowed. A VPN protects your privacy by changing your IP address, making it harder to associate your online activity with your true identity.
Creating your own VPN on a virtual private server is easier than you think!
Why create your own VPN?
If you’re tech-savvy, you might want to build your own VPN just because you can. It’s good to do things yourself, and being the person in charge of your own security and privacy can be empowering.
When you set up your own VPN server, you control everything about it: its physical location, technical specifications, cost, and the level of security and privacy you need.
How to Choose a VPS Provider to Host Your Own VPN
While it’s entirely possible to host your own VPN at home, the security and privacy benefits are limited. Whenever you visit a website, they will be able to see your router’s IP address and link any activity to your household. Since the VPN is in the same country as you, a home VPN will not help you access geo-restricted content.
To access geo-restricted content and to keep your own private IP address when visiting websites, you need your VPN to be located elsewhere, preferably in another country.
Virtual Private Servers (VPS) are computers hosted in data centers around the world. By renting a VPS, you get a complete system that you access and control through a secure shell (a shell is a tool that lets you enter commands and run text-based programs).
If you rent a VPS, you can install the software that will allow you to run your own VPN.
The prerequisites are minimal: you need a credit card (or crypto), and some technical knowledge, or at least the will to learn. If you’re not sure you have the necessary skills, you should consider using a commercial VPN and read up on the best VPNs compatible with Windows 11.
There are many VPS providers available. Here are some things you need to consider when choosing one.
No VPS provider offers servers in every country in the world, and many are limited to a few large territories. If you’re setting up your own VPN to bypass geo-restrictions, you need your VPS to be a region where the content you want to access is already legally available.
If you plan to use your VPN to hide your online identity and location, but otherwise use the Internet as you usually would, a VPS in the same country as you would be a good idea.
Make sure you know where you want your VPN to be based and select a VPS provider with servers in that area.
Who do you turn to when things go wrong or you can’t connect to your VPS? Your supplier should be easy to contact in the event of a problem and have an in-house help desk run by experts who know what they’re talking about.
Think about how much traffic you will pull through your VPS-based VPN. Most providers will have usage caps for data, as well as maximum speeds that are much lower than what you would get from your bare router or a commercial VPN.
Security, privacy and logs
If you’re setting up a VPN to keep your identity and activity secret, it can be uncomfortable knowing that another company has access to your true identity and can know everything you do on your machine.
Make sure your provider offers two-factor authentication (2FA); 2FA has its pros and cons, but if someone gains access to your virtual machine, they may be able to modify it or run malware without your knowledge.
Price and value
Prices for virtual private servers vary wildly. A good but basic VPS from Digital Ocean with 16 GB of RAM and 8 processors costs around $100 per month. A low-end box from Racknerd with 512MB of RAM and a processor will cost less than $10 per year.
Ignore RAM and CPU – a VPN will work fine on a VPS with 128MB of RAM – what you should be looking at is the transfer limit. The Racknerd offer is limited to 500 GB per month, while the Digital Ocean VPS offers 6 TB, 12 times more!
Determine how much data you will transfer and choose accordingly.
Remember that commercial VPNs usually have no transfer limits.
Create your own VPN on a Linux virtual private server
After choosing a provider, selecting a location, and paying for your VPS, choose Ubuntu as your operating system (an Ubuntu server has very low overhead and is very stable), and you’ll be given an IP address and root password. Congratulations! You now have access to a Linux server. You will connect to the server using Secure Shell Protocol (SSH). If you don’t know how to do this, read our guide to using SSH on Windows, Mac, and Linux.
To connect to your VPS type:
When prompted, enter the password.
Having root access enabled on a Linux system is dangerous from a security perspective, so you will need to create a new user and grant them additional rights.
useradd -m new_username
This will create a new user.
And it will allow you to set a password. Note that when entering a password, there will be no on-screen confirmation that you have pressed a key.
Grant your new user sudo powers so you can actually get things done by typing:
usermod -a -G sudo new_username
You will be returned to your client computer and will need to log in again as a new user:
You will also need to install some basic utilities:
sudo apt install zip unzip
sudo apt install -y
Configure Algo VPN on your Linux VPS
Rather than installing all the software components one by one, you’ll use Algo VPN, a set of scripts to simplify setting up a personal WireGuard and IPsec VPN. Full details are available on GitHub.
You should pay close attention to the disclaimers, especially “Does not claim to provide anonymity or avoid censorship”.
If you have read the documentation and are happy to continue:
This will download the package. Now:
This will extract it to a new directory: master-algo.
Navigate to the new directory:
And enter the following command:
python3 -m virtualenv --python="$(command -v python3)" .env && source .env/bin/activate && python3 -m pip install -U pip virtualenv && python3 -m pip install -r requirements.txt
Setup and configuration will take about five minutes (or more if you’ve gone with a cheap VPS), so take the opportunity to make a cup of tea or walk the dogs. Eventually, you will be returned to the input prompt.
By default, Algo has three predefined users. These are: phone, laptop, desktop and you can have up to 65,534 users in total.
To edit users or add new ones:
In the Users section, edit or add entries. Usernames starting with 0 or containing only digits should be protected with double quotes, e.g. “000david” Where “123.”
Save the file with CTRL+o and go out with CTRL+x.
Now it’s time to deploy the server, so type:
At the first prompt, “Which provider would you like to use?”, type 12 and press return.
The remaining prompts are largely down to personal choice, such as: “Do you want macOS/iOS clients to enable ‘Connect on Demand’ when connected to cellular networks?” “Do you want to enable DNS ad blocking on this VPN server?”
An important question is: “Do you want to keep the keys (PKI)?” Choosing to keep keys will allow you to add users to your VPN in the future, but in some extreme cases it may be less secure. Again, this is up to you and your own threat perception values.
Once the installation is complete, you will see a message saying “Congratulations!, your Algo server is running”.
You can now configure and connect to your own VPS-based VPN!
Setting up your own VPN is quick and easy, especially if you carefully follow our step-by-step instructions. Remember that your VPS provider has access to your real name, location, and payment information. Unlike commercial VPN providers who strive to keep law enforcement at bay, VPS providers will pass information on demand. Don’t do anything illegal!