easyrsa
openvpn
or other VPN GUI ClientFirst of all, we need to create our own cert signing system called PKI (public key infrastructure).
This can be done with openssl
command but much easier with OpenVPN’s easyrsa
library.
Below is the way to generate cert with easyrsa
$ git clone https://github.com/OpenVPN/easy-rsa.git
$ cd easy-rsa/easyrsa3
$ ./easyrsa init-pki
$ ./easyrsa build-ca nopass
$ ./easyrsa build-server-full server nopass
$ ./easyrsa build-client-full client1.domain.tld nopass
$ aws acm import-certificate \
--certificate fileb://server.crt \
--private-key fileb://server.key \
--certificate-chain fileb://ca.crt
See the last command,
The word key chain is 1+2 cert that sign from another cert.
Go to the console and browse to the VPC → VPC Client Endpoint → Create Endpoint.
Client CIDR must NOT have ANY overlap with your VPC.
This is the pool where client IP will fall into.
If you haven’t yet setup Inbound DNS Server skip this you can edit it later.
Full tunnel make your traffic no matter where you go e.g. google.com through VPN. Split tunnel make ONLY ip range or host name you define go through VPN.
After you’re done creating the Endpoint, you will see the screen similar to image below.
At this point the status is ‘Pending Association’.
You need to pick the drop-down and associate the VPC and landing subnet to this endpoint.
The final step is to add ‘Ingress rule’, in my case I authorize the whole network 10.0.0.0/16
and allow all users.
Now our VPN is working, but we need to access each machine with IP.
If you don’t want the DNS (host name → IP mapping), you can skip to step 6.
Go to Route 53 → Resolver → Inbound endpoints → Create inbound endpoint
AWS require you to setup at least 2 subnet in 2 AZ (Availability Zone)
Fill in the subnet, this is where the End user query the DNS.
Don’t worry about how. VPN will PUSH this to the client. You will see in the Step 6.
Don’t forget to edit your VPN Endpoint to set to this resolver IP. See step 2.
Route 53 → Hosted zones → Create hosted zone
Then associate this with your VPC.
Download the VPN config file in
VPC console → Client VPN Endpoint (sidebar) → Download Client Configuration
Then you will got .ovpn
file.
Now you replace the red text with the root cert, CLIENT cert, CLIENT private key generated in Step 1.
sudo openvpn --config ~/path/to/client-config.opvn
You must see the DNS push like this. Your Inbound DNS IP will show here.
and after that you must see the route table modified
ip route listORnetstat -nr
saying the traffic will go through VPN if in 10.0.0.0/16
and else otherwise.
Sometimes the DNS host is loaded but not correctly set. We have to manually set it with update-resolv-conf
command.
script-security 2
...
...
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf
If you are on mac, Tunnelbrick is a GUI alternative for this.
If you are on Ubuntu or other Gnome Linux, OpenVPN is built-in in the network panel.
Here we go.
See you then !