Skip to content

OpenVPN Setup on Ubuntu 20.04 Server and Client Machine

Notifications You must be signed in to change notification settings

gig-tech/OpenVPN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenVPN Setup on Ubuntu 20.04 Server and Client Machine

Requirements

Important files

Python script to provision virtual machine, create port forwards and install OpenVPN Cloud-init.

openvpn_installer.py

Set environment variables in your shell (Linux / Mac)

export MY_JWT = ""

Copy public your public ssh key into openvpn/openvpn_installer folder to enable you to access the server remotely after installation

cp <ssh_pub_key> openvpn/openvpn_installer/

Running the Python Scripts

The scripts can run in any Python 3 environment. In this case, a docker container based on the GiG docker tools image will be used.

Create docker image

Clone GIG Tools docker repository

git clone [email protected]:gig-tech/GIG-Docker-Tools.git

Set environment variables

ARG_JWT=

ARG_VCO_API_URL=

export ARG_JWT

export ARG_VCO_API_URL

Build Image

cd gig_tools/cli_terraform

docker build --build-arg ARG_JWT --build-arg ARG_VCO_API_URL -t <vco_name> .

Clone OpenVPN repository

cd <working_dir>

git clone [email protected]:gig-tech/OpenVPN.git

cd openvpn

Important Note

  • Add your JWT to env_list file variable -> MY_JWT= using your favorite editor.

Run container and script to set up OpenVPN server

docker run --env-file env_list -w /root/home/ --mount type=bind,source=$PWD,target=/root/home -i -t <vco_name> /bin/bash

pip3 install pipenv

pipenv shell

pip3 install requests paramiko scp click 

python3 openvpn_installer/openvpn_installer.py deploy-server --help

Create and download client1.ovpn

Installation of OpenVPN takes about five minutes. This command will not work until the installation is complete. You will get "..File not found!" message if attempted before 5 mins have elapsed.

python3 openvpn_installer/openvpn_installer.py --help

Transfer client file to Windows and Linux machines

For windows

  • Import client file into VPN client.

Linux Client

  • Install OpenVPN client using
sudo apt update

sudo apt install -y openvpn resolvconf openvpn-systemd-resolved easy-rsa

openvpn --config client1.ovpn # Place your client1.ovpn file in your current directory
  • If systemd-resolved - comment out the following block of code in the client config file
script-security 2

up /etc/openvpn/update-systemd-resolved

down /etc/openvpn/update-systemd-resolved

down-pre

dhcp-option DOMAIN-ROUTE .
  • Or update-resolv-conf - comment out the following block of code in the client config file
script-security 2

up /etc/openvpn/update-resolv-conf

down /etc/openvpn/update-resolv-conf

Try and ping the server on private IP in the cloudspace

ping xyx.xyx.xyx.xyz

About

OpenVPN Setup on Ubuntu 20.04 Server and Client Machine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published