How to Build a Free VPN on Oracle Cloud with OpenVPN (Complete Guide)
Want to create a free VPN on Oracle Cloud with OpenVPN? In this updated guide, you will learn the complete step-by-step process, with a focus on security, firewall configuration, and Android connectivity.
In this tutorial, you will learn how to create a free VPN server using Oracle Cloud and OpenVPN. With growing concerns about online privacy and security, a VPN (Virtual Private Network) has become an essential tool for protecting your connection, masking your IP address, and ensuring secure access to private networks. OpenVPN is one of the most popular and reliable solutions for building a VPN, offering robustness and flexibility.
By using Oracle Cloud’s free tier, you can set up a VPN server at no cost, ideal for both personal use and small teams that want to browse anonymously or securely access private resources remotely. We will show you step by step how to configure the server, adjust the firewall, and connect to the VPN directly from your Android device.
Whether you are a beginner or an advanced user, this simplified guide will help you quickly set up your own VPN safely and efficiently.
Important step!
The region you choose determines where your server will be physically located, which affects latency and VPN connection speed. When creating your trial account, pay close attention to this, as it will be the origin of the access made through the VPN. For our test, I chose Chicago.

Create your account at: https://www.oracle.com/br/cloud/free/
Server configuration
Once access to the dashboard is enabled, create the server by clicking Create a VM Instance:

Under Image and Shape, choose Ubuntu 22 and AMD:



The minimum required to run an OpenVPN server is 1 CPU and 1 GB of RAM (https://openvpn.net/as-docs/system-requirements.html#processor). In this case, I configured it with 4 GB of RAM:

At this stage, create a private key for SSH access to the server using PuTTYgen. It is installed together with PuTTY:

Click Generate and move the mouse around inside the box until key generation is complete:

Next, save the public and private keys in a safe location (Save public key and Save private key). Copy the generated code and paste it into the page where you are creating the server, under Add SSH Keys, selecting the Paste public keys option:

Finally, click Create. Once it finishes, on the home screen you will see the following information about your VM:

With your public IP address and username. Open PuTTY so we can connect via SSH:

Under Category on the left, go to Connection -> SSH -> Auth -> Credentials, select the .ppk file generated earlier, and then click Open to connect:

OpenVPN installation

For security, update your server before starting:
$ sudo apt update
$ sudo apt upgrade -y
$ sudo reboot
Once it is finished, your VM will restart, and we can reconnect to begin installing the OpenVPN server. There is a script that makes setting up your server much easier; just download it and run it:
$ wget https://git.io/vpn -O openvpn-install.sh

$ sudo chmod +x openvpn-install.sh
$ sudo bash openvpn-install.sh
In my case, it automatically detected my external IP. If it does not, enter it in the first step. For the rest, you can fill it out as I did below:

When it finishes, it will tell you where it created your configuration file and mention that, if you need to create files for new clients, just run the script again:

Just to confirm that it is running:
$ sudo systemctl status openvpn-server@server

Firewall configuration
Now we need to allow the required traffic through both firewalls: Oracle’s and the VM’s. Back in the Oracle dashboard, click on your subnet:

Then click Default Security List:

Under Ingress Rules, we will add two rules: one for the OpenVPN UDP connection and another temporary one so you can download your configuration file more easily. Click Add Ingress Rules:



After creating these two rules, we also need to allow traffic on the VM itself. The Oracle image already comes with some predefined rules, so it is easier to leave it open there and manage access through the web interface. On the VM, run the following command to clear the rules:
$ sudo iptables --flush
Downloading the configuration file
We will create a temporary web server to download the configuration file we generated. To do that, we need to become root, navigate to the directory, and run the command to start the web server with Python3:
$ sudo -i
# python3 -m http.server 8090
After starting the server, open a new browser tab, access your VM’s public IP on port 8090, and download the ovpn file:


To stop the server, just press Ctrl + C, and now we can install it on our phone. If you do not have it installed yet, download OpenVPN from the Play Store. Once installed, open the ovpn file on your phone; when it asks which app you want to use, select OpenVPN:

Confirm that you want to import the file, then just enable your new VPN and browse privately:


Note: If, after the Oracle Cloud free period ends, you want to keep using a reliable, specialized VPN, I recommend NordVPN. They currently have an exclusive offer: up to 73% off + 3 extra months! Take advantage of this opportunity to protect your data with one of the best VPNs on the market. Use the link below to secure the discount and support this blog:
📚 Related reading
Frequently asked questions (FAQ)
1) Does Oracle Cloud Always Free really allow you to run a VPN at no cost?
Yes, as long as your instance remains within the free-tier limits and your region has available capacity.
2) Which protocol should I use in OpenVPN: UDP or TCP?
For better performance, UDP is usually the best choice. TCP can help on more restrictive networks.
3) Is it safe to expose the download port for the .ovpn file?
Only temporarily. After downloading the configuration file, remove the firewall rule and shut down the HTTP server.
4) Can I connect more than one device?
Yes. Run the script again to generate new client profiles and revoke old profiles that are no longer in use.
5) Does this VPN replace a commercial VPN?
It depends on your goal. For lab work and personal use, it works very well. For continuous use and dedicated support, commercial services may be more practical.
💜 Enjoyed this content? Support the blog with USDT (TRC20):
TX7obcjHQbDUXb4mGqoASEu1QFTKT2CFGG
