How to connect your home systems to a VPN on AWS in under 30 mins : Home Lab — Part 2

Basic architecture

Create an EC2 Instance

  1. 1 GB Ram and 1 vCPU
  2. At least 20GB storage
  3. Public IP
  4. Ubuntu AMI (You can use any other linux AMI but to follow along ubuntu would help)

Setup VPN on EC2 Instance

ubuntu@ip-10-1-22-109:~$ ifconfig tun0
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 10.8.0.1 netmask 255.255.255.0 destination 10.8.0.1
inet6 fe80::da79:ab62:946f:51b0 prefixlen 64 scopeid
.....
.....

Connect all nodes to VPN

ubuntu@ip-10-1-22-109:~$ sudo ./openvpn-install.sh 
Welcome to OpenVPN-install!
The git repository is available at: https://github.com/angristan/openvpn-install
It looks like OpenVPN is already installed.What do you want to do?
1) Add a new user
2) Revoke existing user
3) Remove OpenVPN
4) Exit
Select an option [1-4]: 1
Tell me a name for the client.
The name must consist of alphanumeric character. It may also include an underscore or a dash.
Client name: node1
Do you want to protect the configuration file with a password?
(e.g. encrypt the private key with a password)
1) Add a passwordless client
2) Use a password for the client
Select an option [1-2]: 1
# At the end you should have a node1.ovpn file at your home directory
ubuntu@ip-10-1-22-109:~$ ls -lrth node1.ovpn
-rw-r--r-- 1 root root 2.8K May 22 19:35 node1.ovpn
# Install openvpn clinet
sudo apt install openvpn
# Create a new file with name myvpn.conf and copy contents of node1.ovpn into it sudo cp mypvn.conf /etc/openvpn/
sudo systemctl enable openvpn@myvpn
sudo systemctl start openvpn@myvpn
# Ensure VPN is UP 
vikas@home-pc ~ ❯❯❯ sudo systemctl status openvpn@mypvpn
● openvpn@myvpn.service - OpenVPN connection to myvpn
Loaded: loaded (/lib/systemd/system/openvpn@.service; indirect; vendor preset: ena
Active: active (running) since Sat 2021-05-08 01:03:40 IST; 2 weeks 1 days ago
Docs: man:openvpn(8)
# Ensure you are able to ping the vpn server. 10.8.0.1 is the IP of your EC2 instance on the VPN
vikas@home-pc ~ ❯❯❯ ping 10.8.0.1
PING 10.8.0.1 (10.8.0.1) 56(84) bytes of data.
64 bytes from 10.8.0.1: icmp_seq=1 ttl=64 time=34.9 ms
64 bytes from 10.8.0.1: icmp_seq=2 ttl=64 time=34.8 ms
64 bytes from 10.8.0.1: icmp_seq=3 ttl=64 time=34.8 ms
^C
--- 10.8.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 34.825/34.878/34.920/0.039 ms

--

--

--

SRE at Linkedin

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Running SQL on Apache Druid — Part I: How to run queries

Loading_data

Composition & Visualization

The Expectations and Realities of Google Analytics App + Web

An icon of a mobile device over an icon of a monitor

Python List (Part III)

Intro the Class Inheritance

Whats the fuss with Pay per Second Cloud Billing ?

Flutter x PWA Tutorial

Build Radar System with Arduino Uno and Ultrasonic Sensor.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vikas Yadav

Vikas Yadav

SRE at Linkedin

More from Medium

Getting Started with HashiCorp Packer

A Gentle Introduction To Kubernetes

[k8s] How to mount local directory (persistent volume) to Kubernetes pods of Docker Desktop for Mac?

AWS: Trusted Advisor, part 2 — CloudWatch Alarms and Slack notifications