DEV Community

Cover image for Install VPN (OpenVPN) Server on AWS EC2 Instance (Ubuntu)
ピメン.ヴィ.ブリタニア
ピメン.ヴィ.ブリタニア

Posted on

10 3

Install VPN (OpenVPN) Server on AWS EC2 Instance (Ubuntu)

I think you can use ec2 free tier to create your own vpn server instead of buying or using free limited vpn, hm...

First, you need to login to your aws console and find ec2 service, then create a new instance (launch intance):
***Image description

  • Select free tier instance type
  • Generate your own key-pair (required to connect with ssh)
  • On network setting click edit
    • Click add security group rule then add new rule for custom UDP with port range = 1194 and source type from anywhere
    • Image description
    • Image description
  • Then on Advanced detail setting scroll to bottom and you will find User data field, and fill with:


#! /bin/bash
apt-get update
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh

chmod +x openvpn-install.sh

APPROVE_INSTALL=y ENDPOINT=$(curl -4 ifconfig.co) APPROVE_IP=y IPV6_SUPPORT=n PORT_CHOICE=1 PROTOCOL_CHOICE=1 DNS=1 COMPRESSION_ENABLED=n  CUSTOMIZE_ENC=n CLIENT=david PASS=1 ./openvpn-install.sh 


Enter fullscreen mode Exit fullscreen mode
  • Then Launch instance.

After instance created, you can login into instance with your instance key-pair.pem, then you can install openvpn-install to generate your account/configuration file (.ovpn).

When installed, you can generate file by running:



sudo ./openvpn-install.sh


Enter fullscreen mode Exit fullscreen mode

You can copy the configuration file into your local machine, and install OpenVpn client (windows) or Tunnelblick (MacOs), then CONNECT!!

Image description

Billboard image

Monitor more than uptime.

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay