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.
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.
- 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".
- Now use below command to switch root user:
sudo su -
- 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
- 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
- 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
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: