The OpenVPN Community Edition (CE) is an open source Virtual Private Network (VPN) project. It creates secure connections over the Internet using a custom security protocol that utilizes SSL/TLS. This community-supported OSS (Open Source Software) project, using a GPL license, is supported by many OpenVPN Inc. developers and contributors as well as the extended OpenVPN community. CE is free to deploy, but it does require a strong understanding of Linux and using the command line interface.

OpenVPN Tunneling Protocol

The OpenVPN tunneling protocol uses the Secure Socket Layer (SSL) encryption protocol to ensure data shared via the Internet remains private using AES-256 encryption. Because the code is available for audits, anyone can find — and fix — vulnerabilities. It’s not only considered the most secure VPN tunneling protocol, it also delivers faster connections and can bypass most firewalls.

 

Diagram

Pre-requirements

Free resources you will need to build this docker project:

Pre-installed services:
  • Docker, Docker-Compose (Using Ubuntu OS for the commands)
    • apt update
    • apt install docker.io
    • apt install docker-compose
    • apt upgrade docker.io
  • Portainer (Optional)
    • docker volume create portainer_data
    • docker run -d -p 9000:9000 –name portainer –restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
  • aapanel with Nginx (Optional)
  • Nginx Proxy Manager (Optional)

Docker Run or Docker-Compose

Github Project:  https://github.com/dockovpn/dockovpn

Prerequisites

To get started with this one command Docker OpenVPN installation, you’ll have to have a few things:

  • Linux server
  • Public IP address
  • Docker

1 Install docker and docker-compose

  • apt update
  • apt install docker.io
  • apt install docker-compose

2 run one line command

original command from Github

docker run -it --rm --cap-add=NET_ADMIN \
-p 1194:1194/udp -p 80:8080/tcp \
-e HOST_ADDR=$(curl -s https://api.ipify.org) \
--name dockovpn alekslitvinenk/openvpn
A little bit modification with -d option:
docker run -itd --rm --cap-add=NET_ADMIN \
-p 1194:1194/udp -p 80:8080/tcp \
-e HOST_ADDR=$(curl -s https://api.ipify.org) \
--name dockovpn alekslitvinenk/openvpn

More with persisting configuraiton:

You will need to create a local folder at /opt/Dockovpn_data folder first.
docker run -itd --rm --cap-add=NET_ADMIN \
-p 1194:1194/udp -p 80:8080/tcp \
-e HOST_ADDR=$(curl -s https://api.ipify.org) \
--name dockovpn alekslitvinenk/openvpn \
-v openvpn_conf:/opt/Dockovpn_data

3 Outputs

root@ub20-1-test:~# docker run -itd --rm --cap-add=NET_ADMIN \
> -p 1194:1194/udp -p 80:8080/tcp \
> -e HOST_ADDR=$(curl -s https://api.ipify.org) \
> --name dockovpn alekslitvinenk/openvpn
Unable to find image 'alekslitvinenk/openvpn:latest' locally
latest: Pulling from alekslitvinenk/openvpn
29291e31a76a: Pull complete
ee9d0fc0608b: Pull complete
050f6b5684f5: Pull complete
3df1fe3bf9f7: Pull complete
7663deeb3206: Pull complete
ee20c2e12945: Pull complete
Digest: sha256:86480f318120c9db963cd431ed08cd240c5eac1c3f74de689476ab68a4666765
Status: Downloaded newer image for alekslitvinenk/openvpn:latest
45f835677b614b285826a6bdfdd735ae9b24307b3605b58d27cd9a858837a4b7
root@ub20-1-test:~#
Make sure your VPS opened two ports: tcp 80, and udp 1194. 

4 open http://<Public IP> to get your client profile which will be imported to your OpenVPN Client. 

Once this http port accessed, it will be automatically shutted down. No more http opened to the world. 

5 Download OpenVPN Client for Windows

OpenVPN Connect – Client Software For Windows | OpenVPN

Double click to install it.

6 Run OpenVPN client and import step 4’s downloaded file 

You will see your vpn profile has been added . Click connect:

Super Simple and easy:

Verify your ip address from What Is My IP? Best Way To Check Your Public IP Address  and speed from Internet Speed Test | Fast.com. Your Public ip will be changed to your VPS’s ip now. 

The downside of it is the speed performance might be limited by both of your VPS and internet connection. 

Install from Cloud Provider’s Marketplace

From Oracle

1 Log in to Oracle Cloud Account

2 From Dropdown menu to choose marketplace then choose all applications

3 Search OpenVPN

4 Lauch Instance

5 Create a free instance

Make sure ports 80/443/943, 1194 are open to the public.

Direction Source Type Source Protocol Source Port Destination Port
Ingress CIDR 0.0.0.0/0 TCP All 943
Ingress CIDR 0.0.0.0/0 TCP All 22
Ingress CIDR 0.0.0.0/0 TCP All 443
Ingress CIDR 0.0.0.0/0 TCP All 945
Ingress CIDR 0.0.0.0/0 UDP All 1194
You might need more ports, please check the quick start guide at https://openvpn.net/vpn-server-resources/oracle-quick-start-guide/

Videos

 

References

By netsec

Leave a Reply