Build your own VPN with Ansible

Last Updated 2021-06-02

Author’s Note: This article has been updated to present a streamlined approach for configuring a VPN using Ansible and Infrastructure as Code (IaC) principles.

In an age where online privacy is a growing concern, relying on commercial VPN providers can leave you questioning the security of your data. Many VPN services claim to offer no-logs policies, but verifying their practices can be challenging. In this article, we’ll guide you through the process of building your own VPN from scratch using a Virtual Private Server (VPS). This DIY approach provides you with a dedicated IP address, circumventing VPN blocklists, and offers a cost-effective and privacy-focused alternative to commercial VPN services.

Requirements

Before you begin, ensure you have the following:

Instructions

Follow these steps to set up your VPS and deploy the ansible-easy-vpn script:

1. Initial Login to VPS

Log in to your VPS using SSH. You can obtain the login information and IP address from your service provider.

ssh user@your_server_ip

Replace user with your SSH username and your_server_ip with your VPS’s IP address.

2. Prepare the OS

Run the following command to prepare the operating system. This script automatically detects your OS and performs the necessary preparations.

wget https://notthebe.ee/vpn -O bootstrap.sh && bash bootstrap.sh

This script checks the OS type and version and installs the required packages and dependencies. Follow the prompts and provide the requested information, such as your desired username, password, domain name, DNS settings, and more.

3. Complete the Configuration

After providing all the requested information, the script will prepare the VPS for the installation of the ansible-easy-vpn. It will also ask if you want to run the playbook immediately. If you choose to do so, the playbook will be executed, and your VPS will be set up accordingly.

4. Follow Additional Prompts

Depending on your specific configuration choices, the script may prompt you for additional details such as email server information and SSH key selection. Provide the necessary information as requested.

Notes

References