Have you considered harnessing the power of AWS Hosting and OpenVPN to curb your skyrocketing VPN service costs? If your bills are burning a hole in your pocket, it’s time to explore an alternative solution: setting up OpenVPN on an Ubuntu EC2 instance with AWS Free Tier. This technical task becomes a piece of cake using the AWS console, even for the uninitiated.
Absolutely free for the first year, this setup empowers you to surf the internet securely from any corner of the world without worrying about pricing. Our step-by-step guide simplifies the installation and configuration process, ensuring that you can easily transition to this cost-effective, secure internet browsing solution. Time to bid farewell to exorbitant monthly bills and embrace the freedom and security of OpenVPN on AWS Free Tier.
What is OpenVPN?
OpenVPN is a widely recognized, open-source software solution that helps create secure point-to-point or site-to-site connections in routed or bridged configurations and remote access facilities. It utilizes a custom security protocol that uses SSL/TLS for key exchange, providing a versatile and powerful privacy tool for your online activities. The OpenVPN download on your server is essential to unlocking these benefits. We will not use the official release; that takes time. We will use the repository from Git for OpenVPN download and installation. By acquiring the OpenVPN client, users have the necessary software to establish a secure connection with the OpenVPN server. For Android or iOS or even Windows and Mac, the app is called ‘OpenVPN connect,’ which enables secure data transmission across the internet. OpenVPN offers a robust solution for anyone concerned about online privacy. With easy-to-follow setup procedures, protecting your online activities’ has never been simpler. So why wait? Start your journey towards secure, private internet browsing today with OpenVPN.
Prerequisites to Install OpenVPN on Linux (AWS EC2 Ubuntu Instance)
- AWS Free Tier (Follow How to get AWS Free Tier for One Whole Year if you haven’t got one already)
- AWS EC2 Ubuntu 22.04 instance (Follow this Step by step guide to create an Ubuntu Server EC2 instance on AWS if you don’t know how)
- AWS Console (Not AWS Management Console, PuTTY or MobaXterm (i.e. access to SSH port) you can also access using EC2 Instance Connect from AWS Management Console though)
- openvpn-install.sh from GitHub Repository
I’m guessing you have accessed the AWS EC2 Ubuntu 22.04 Instance via PuTTY, MobaXterm, or any SSH Terminal already. Let’s start after that,
How to Install OpenVPN Server on AWS EC2 Ubuntu Instance
Get root Privilege
Geitting root privilege is the first thing you need to do. Just copy and paste the following command to your AWS EC2 Ubuntu terminal
OpenVPN download using openvpn-install.sh script to set up OpenVPN server
Type the following wget command or simply copy and paste it on your terminal
wget https://git.io/vpn -O openvpn-install.sh
Verify the openvpn-install.sh script (optional)
Additionally you can verify the script by concatenate or following
Make openvpn-install.sh script executable
Copy and Paste the following command on your ssh client to make
openvpn-install.sh script executable on the AWS EC2 ubuntu server.
chmod +x openvpn-install.sh
Execute (Run) the openvpn-install.sh script
Copy and paste the following command into your ssh client and hit enter to start the installation
Choose your parameters for OpenVPN installation
- Here you need to enter your hostname at the first step. I have used
ovpn.roosho.com. It is not mandatory. You can always hit enter to go to next step if you don’t have a domain. But I recommend it. If you have enter the hostname, follow this instruction to add it into your domain control panel.
- In step 2 Select 1 for UDP or 2 for TCP as the OpenVPN Protocol. I’ve selected
UDP. You can just Hit Enter if you also want to keep UDP which is default.
- Step 3 is selecting the port. Here I’ve selected port
8888. That makes my VPN port UDP 8888. Here also you can Hit Enter and Continue with the default port
1194. Whatever you choose, don’t forget to add the inbound rule for that port inside Security Groups of that Instance on aws amazon console.
- In step 4 choose your DNS server, I’ve chosen
- Enter the name of your first client. I’ve entered
- Hit enter to complete your installation.
Get the configuration file to use in OpenVPN Connect
You can actually get the
ovpn file location which you need to use on OpenVPN Connect at the end of the installation. If you still can’t find the file try the following command.
find / -type f -name "r_roosho.ovpn"
My OVPN is
r_roosho.ovpn. Change your filename accordingly. If you don’t know what is the name of your OVPN file use the following.
find / -type f -name "*.ovpn" -ls
Copy the OVPN file to your Computer
It is actually hard to get direct access to the root directory of the AWS EC2 Ubuntu Server, and also time consuming. The easiest way is to just copy what’s inside it using
cat. Simply enter the following command. Change the filename according to your installation.
Once you see it, copy everything inside it.
Then paste it on a notepad on your computer and save it with an OVPN extension.
How to Add Inbound Rule to AWS Firewall
- Select your AWS EC2 Ubuntu Server
- On the
SecurityTab and select
- Click on
Edit Inbound Rulesto add another Inbound Firewall Rule
- Click on
Select Type as
Custom UDP, Port range whatever you set(in my case
8888). and IP Range
0.0.0.0/0 for all IPv4, lastly Optional Description if you want to add Click on Save rule.
How to add DNS to your Hostname of your domain
If you have used a hostname like mine, Go to your Domain Control Panel and then add an
A Record with your domain. Enter
hostname from your
hostname.domain.com in place of
Name textbox Enter your AWS EC2 Ubuntu Instance (Ubuntu Server) IP in place of DNS (In my case hostname is
ovpn and DNS is
18.104.22.168). If you are using CloudFlare, please please please, don’t forget to turn off your Proxy. And
Save it. Done.
Now you can use it on any devices. Let’s see how to use it on Android Smart Phone.
How to use OpenVPN on Android using OpenVPN Connect
- First of all Download the OVPN on your Smartphone. If you don’t have any easy way like Microsoft Phone Link or KIES or PC Suit, You can use HFS to create a temporary HTTP URL within seconds. If you don’t know how, I don’t know why, Just follow this guide of How to Create your Http File Server in seconds with HFS.
- Download and Install the OpenVPN Connect from PlayStore in your Android Smartphone. Go to this link if you are on Your Phone right now.
- Open the Open VPN application.
- On the Left Hamburger Menu Select
- Import the OVPN file from the download location to your OpenVPN Connect App.
- Connect to your VPN and check you IP from web Browser.
How to Review OpenVPN Installation on Ubuntu Server
OpenVPN Firewall Configuration
You can review the added firewall rules by the following command.
systemctl cat openvpn-iptables.service
Review your overall OpenVPN Configuration using the following command.
sudo more /etc/openvpn/server/server.conf
How to see Status of your OpenVPN Service on Ubuntu Server
Start OpenVPN Service
To start OpenVPN Service on your Ubuntu Server use the following command (if needed).
systemctl start [email protected]
Stop OpenVPN Service
To stop OpenVPN Service on your Ubuntu Server use the following command (if needed).
systemctl stop [email protected]
Restart OpenVPN Service
To restart OpenVPN Service on your Ubuntu Server use the following command (if needed).
systemctl restart [email protected]
Status of your OpenVPN Service
To see the status of your OpenVPN Service on your Ubuntu 22.04 Server use the following command (if needed).
systemctl status [email protected]
How to add a new user to OpenVPN
Enter the following command to start Adding new user to your OpenVPN Ubuntu Server
Enter 1 and Press Enter then write the name and Hit Enter to create a new user on your OpenVPN server.
In conclusion, setting up your own VPN server using AWS Free Tier and OpenVPN can be an efficient and cost-effective solution to secure your online activities. This guide provides detailed step-by-step instructions on how to leverage the power of AWS and OpenVPN, offering you a robust privacy tool at your disposal. With AWS Free Tier, you can enjoy this service free of cost for the first year, potentially saving you a significant amount on your monthly bills.
However, the technical nature of setting up a VPN server can be a daunting task. But fear not, the outlined guide has simplified the installation and configuration process for you. From gaining root privilege, downloading and executing OpenVPN scripts, to setting up your parameters and importing the configuration file, each step is clearly laid out for you. You can also learn how to manage the OpenVPN service on your Ubuntu Server and add a new user when needed.
Furthermore, this guide extends to demonstrating how to use the OpenVPN on an Android smartphone, making your secure browsing experience mobile.
Yet, no setup is entirely devoid of challenges. If you encounter any issues, need help troubleshooting, or simply need assistance in understanding any part of this guide, do not hesitate to reach out. I am here to help ensure that you successfully transition to this secure, private, and cost-effective internet browsing solution.
Remember, your online privacy is paramount and taking these steps to secure your internet browsing is an investment in your own digital safety. Embrace the freedom and security that comes with using OpenVPN on AWS today.