Follow us

Free OpenVPN Setup For Your Organization

 

When you have private resource like open search Kibana dashboard url, or you have aws RDS instance which is private or even ec2 instance with private subnet and private ip only or even you want to allow RDS of your machine from PVN machine IP only. All such resources if you want to access from your local machine, you need VPN, so that it will make trusted private network connection between your local system to cloud infrastructure and then you will be able to use those resources from your system.

VPC 
Security Group - where 
inbound rule allowed with vpn 
VPN Connect ion 
Anv 
PubEc Subr*t 
Private Subnet

 

 

 

There are paid cloud version to setup VPN server and you will get UI option to manage user/client profile. But as its paid service, that means it will cost your more, so question is how can use free OpenVPN for your organization and the simple answer is that, create your own cloud small linux instance and then install the free VPN and manage users/clients vai terminal(SSH connection). So by doing this, it will only charge you EC2 instance cost.

 

To setup free open VPN server, follow below steps.

 

  • Create Linux ec2 machine from AWS console. You can instance t2 micro instance.

Instances (1/1) Info 
Q Search 
Name 
linux-for-open. 
v 
Instance ID 
i-Od12faa5f4b2427a9 
Instance state v 
@ Running QQ 
Instance type 
t2.micro

  • Make sure public ip enabled for this instance.
  • While create ec2 instance, create/download key pair (.pen) file for your instance which will help you to make SSH connection.
  • With your security group, allow inbound rule for SSH port 22 which will help you to make SSH connection to your Linux machine Open VPN server.
  • Allow inbound rule for UDP port 1194, which is VPN port to make VPN connection.

  • Now with the help of key pair (.pen) and public ip of your VPN server, make SSH connection and login as "ec2-user".

login as: ec2-user 
Authent icating with public key " Imported-Openssh -Key" 
• MobaXterm Personal Edition v22.1 • 
(SSH tent, X server and network tools) 
SSH session to ec2-user@54.234. 137.89 
• Direct SSH 
• SSH compression : 
• SSH-browser 
• Xll-forwarding 
x (disabled or not supported by server) 
For more info, ctrl+click on help or visit our 
Last login: Sat Jul 
9 10:23:21 2022 from 103.46.200.149 
Amazon Linux 2 AMI 
https: //aws.amazon.com/amazon-linux-2/ 
No packages needed for security; 2 packages available 
Run "sudo yum update" to apply all updates. 
[ec2-user@ip-172-31-82-113

  • Now use below command to switch root user:

sudo su -

Cec2-user@ip-172-31-82-113 NI$ sudo su - 
Last login: sat Jul 9 UTC 2022 on pts/l 
[root@ip-172-31-82-113 I

  • Run below command to install epel for linux machine to have packages support available.

yum install -y epel-release

 

Note: if you get error epel-release not found, then use below command:

sudo amazon-linux-extras install epel

 

  • Run below command to download open vpn installation script

wget https://raw.githubusercontent.com/Angristan/openvpn-install/master/openvpn-install.sh

 

Note: If you get error "wget" does not found, then run below command to install it and then again run above command:

yum install -y wget

 

  • Run below command, you should see the downloaded openvpn-install.sh file

ls -l --

 

  • Run below command to set execution permission to downloaded file

chmod +x openvpn-install.sh

 

  • Run below command to install/setup open vpn server and your first client(vpn profile). It will install the pvn and it will ask you mutliple questions like public ip address, port etc. so either you customise this or go with default selected option. Post that it will ask you for client name, so provide the name you want to have for your open pen client profile which you will use to import and connect with open vpn client. You will also get option to create password for your open vpn client or go with password less:

 

./openvpn-install.sh

 

  • Now when you run below command, you should see the created openvpn client .ovpn file

ls -l

 

  • Run below command to copy your created open vpn profile file to tmp directory, so that you can download it

cp openvpnclientyoucreated.ovpn /tmp

 

  • Now download the above .ovpn file

ltmp/ 
Name 
fon t-unix 
. Test-unix 
I-unix 
NM-unix 
system d-pnvate-09faa 130a34d44dfa21 d7 
system d-pnvate-oqfaa 130a34d44dfa21 d7 
@OpenVPNClient1.ovpn 
@OpenVpnOient2.ovpn Open 
@OpenVpnOient3.ovpn 
Open with default 
open w,th 
Open With default I 
Compare file with.„ 
_4_ Download

 

  • Run below command to check the status of your pvn server:

systemctl status openvpn-server@server.service

 

  • Run below command to enable/activate your pvn server:

systemctl enable openvpn-server@server.service

 

  • Run below command to start your pvn server:

systemctl start openvpn-server@server.service

 

  • VPN server setup is done and now you can download the vpn client and install it on your local machine/laptop and import the .opvn client file and you should be able to connect.

Download vpn client using: https://openvpn.net/downloads/openvpn-connect-v3-windows.msi and use it

OpenVPN Connect 
Profiles 
DISCONNECTED 
OpenVPN Profile 
54.234.137.89 
[OpenVpnClient3] 
OpenVPN Profile 
54.234.137.89 
[OpenVpnClient2] 
OpenVPN Profile 
54.234.137.89 
[OpenVPNClient1]

 

Cmnect 
Profiles 
CONNECTED 
OpenVPN Profile 
54.234.137.89 
[OpenVPNClient1]

  • You can check your IP (what is my IP on your browser) before and after PVN connection and you will find before VPN connection, your IP is your internet provider public ip and after pvn connection, your IP is VPN server IP.
  • To create further new user or revoke existing user access/vpn-profile, run again below command and it will give you step wise option to follow and do the same:

./openvpn-install.sh

 

Welcome to OpenVPN- install! 
The git repos itory is available at: 
It looks like OpenVPN is already installed. 
What do you want to do? 
1) Add a new user 
2) Revoke existing user 
3) Remove Open VPN 
4) Exit 
Select an option [1-4]:

 

Few other uesful commands:

 

  • curl ifconfig.me    --this will give you public ip of your linux machine
  • ifconfig     --you can uset his command to know tunnel created for the vpn connection and its status.
  • route -n --you can know routes of your vpn server

Categories/Tags:

Recent Articles

1

AWS Saving Plan - Cost optimization tips

2
3

AWS RDS Key Concepts & Why you should use it?

4
5

Open-Search/Kibana - Multi Tenancy Setup

See All Articles