Giter VIP home page Giter VIP logo

aws-vpn-server-setup's Introduction

Rolling out your own private VPN server on AWS cloud in 10 minutes

Please refer to the blog article with all details on setting up your VPN server on the AWS cloud using cloudformation templates. You can launch a VPN on any of AWS regions which include Tokyo, Singapore, Sydney, Frankfurt, Ireland, Sao Paulo, N. Virginia, N. California, Oregon, Mumbai, London, Canada central, Bahrain, Stockholm and Seoul.

Video walkthrough on setting up the server

YouTubeVideo

Contributing to this open source project

Overview and how the files are setup

  • At the heart of this setup is the cloudformation template which does all the heavy lifting of setting up the AWS server based on parameters (VPN username, password, passphrase) entered by the user.
  • Please update the Unified-Cloud-Formation.yaml and Unified-Cloud-Formation-Key-Name.yaml (for use with Amazon Key pair to ssh to your instance)

Further support & updates

  • We look forward to your feedback on how we can improve this system.
  • Vast majority of the support requests can be resolved if users wait 5 - 10 minutes after the VPN is created. This is because the IP address output shows before installation of supporting libraries are complete.
  • If you want a static IP then see this ticket
  • We currently setup VPN with PPTP and L2TP-IPSEC. This can be extended to include openvpn support and enhancements.
  • Your commits and code updates are welcome. Changes are only required to src/templates in most cases. Looking forward to all the pull requests :)

Updates

  • 26 Nov 2019, Added support for HongKong and changed VPN method. Also, please note t3 instances are used by default as many new regions do not support t2. This could affect free usage in certain regions.
  • 29 Aug 2019 , Added support for Bahrain and Stockholm.
  • 19 Feb 2018, Added Paris (EU-WEST-3) region support.
  • 2 June 2017, we had comments from a few users that some new AWS accounts take a few hours before the account can be activated to use this service.
  • 4 Feb 2017, Added Ohio (US-EAST-2) region support.
  • 3 January 2017, Added London region support.
  • 11 November 2016, (Mac users) PPTP is not supported on the latest macOS Sierra so please use the IPSEC over L2TP. Please see screenshots and details on setting up L2TP over IPSEC in the blog.
  • 12 September 2016, (Advanced users) See output/Unified-Cloud-Formation-Key-Name.json if you like to have a KEY NAME specified to SSH to the instance. Thanks to @tedi for the pull request.

License

Licensed under the MIT license. Maintained by Webdigi, a Web Development agency in London, UK

aws-vpn-server-setup's People

Contributors

felipeamarante avatar flipy avatar shadowsaw avatar tedicela avatar tedionlinenow avatar webdigi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-vpn-server-setup's Issues

Grant access to VPC resources only

Hello. I know that user may choose on its side if to route all traffic via VPN, or to route to addresses from specific subnet only. Could you hint what to change in the configuration on server side (template) to restrict user routing for VPC resources only.

The case is to have secure bridge to access local AWS resources from mobile devices, while not relying on any complex configuration on user side to switch off VPN-zing of all client traffic.

Not forwarding traffic, IP unchanged on Mac OS X

I used the latest JSON template with Key Pair name from this repo, and the instance started fine. I connected over L2TP from OS X 10.11.6 and it connects succesfully, however my traffic doesn't seem to be routing through my VPN instance. Both my browser and my command line continue to report my original IP address, not the IP of my EC2 instance. I also cannot access my ElasticCache redis cluster behind our VPC, which I could access with OpenVPN. Are there more configuration settings needed either on my desktop or on the server?

VPN is unstable

I have followed the steps on the video and it worked perfectly! Just wondering is it ok that the VPN drops the connection after a random amount of time?

I have also made a connection with my VPN server via SSH, and added 2 extra usernames and passwords. After this, VPN started to present instability, but it would get worst when 3 of us were connected at the same time. Does this have been designed for just one user? Or could maybe this is a known issue?

Thanks in advance for any help you can provide.

Dynamic DNS Feature

It would be great to add a dynamic DNS function to the server, so I tried adding inadyn to the CF template, but I think I broke it. Is there already a feature to use Dynamic DNS installed or can you suggest the best point to add the "apt-get install inadyn" etc to the script?

I know that "broke it" isnt much help, but since I cant SSH into it, I cant retrieve any logs (another question I guess).

Requires VPC

I have issues with the stack it requires to have the EC2 instance built inside a VPC but the template doesn't ask for the VPC or creates one.

screen shot 2015-06-24 at 10 14 53 am

L2TP not working and when ec2 machine restarts, it doesn't work

Hi, as soon as the Cloud formation is created, it works fine with PPTP but not with L2TP.

It connects successfully but it can not browse to any site.

Also I have tried to set up with Elastic Ip , which worked great (with PPTP) but if I stop the instance and start again, it connects but again it doesn't resolve to any site.

Do you have any idea why and how we can fix this?

Error in create VPNSecurityGroup

Hi, When i am trying to use your template, cloudformation tries to create a security group gives me this error.

10:59:54 UTC+0100   ROLLBACK_IN_PROGRESS    AWS::CloudFormation::Stack  MyVPN   The following resource(s) failed to create: [VPNSecurityGroup]. . Rollback requested by user.

Do you know if this template support the logic of VPC, associated with the security groups?

Is good to add in the documentation how can we add more that one user :)

I can do a pull request if you what after i resolve this problem.

Thanks

Web Browsing

Normally when u use a VPN u expect to see the browsing history... in this cloudformation method using the template where do I get the browsing history when i keep the VPN on?

VPN Issues N Virginia and N California - L2TP - Mac

Hey just wanted to say thank you for posting this, when I first set it up originally about 2 months ago was working beautifully.

When I originally set it up I used the N Virginia region and everything was working fine with no issues.

Just recently when trying to use the VPN I keep getting the following error message:

The L2TP-VPN server did not respond. Try reconnecting. If the problem continues, verify your settings and contact your Administrator.

I decided to create another stack using the N California region and it work perfectly for about 20 minutes then I was booted off with the same error message and I couldn't reconnect.

not sure if anyone else has encountered this?

Cannot connect or ping server

Hi thanks for the tutorial. I go through the steps exactly as described but cannot connect to the VPN. I also tried pinging it and got no response. Do you know how I can fix this?

Port 500 not responding

Hi, I'm having problems getting the vpn to connect on both OSX and iOS (iphone). Telnetting to port 1723 work, so proves PPTP is listening, but port 500 gives me a connected refused response immediately. Neither L2TP or PPTP will connect on iOS. L2TP won't connect on OSX either.

I've tried different locations, shorter less complex password, and recreating the stack numerous times. But nothing seems to help.

DNS Probe Error on Linux over PPTP

I'm dual-booting Ubuntu and Windows 10 on the same machine, and the VPN works when I connect to it from Windows. So I tried using the default template and connecting to the VPN in Linux (Ubuntu 17.04). After connecting to the VPN, every time I tried to load a website I'd get a bad DNS probe error in Chrome, and the page just wouldn't load in Firefox. Because I'm located in China, I thought it might have to do with the fact that China blocks Google servers, so I changed the DNS addresses in the template to use Open DNS, to no avail.

I used Ubuntu's native network connection managers to create the VPN connection, using MPPE, stateful encryption, BSD compression, deflate compression, and TCP header compression. I've also tried manually inputting the Open VPN addresses into the Ubuntu VPN configuration manager, which didn't work either.

IP address

Hi - Is IP address assigned by cloud formation stack elastic IP? If not, would it change on instance restart? Thank you.

CREATE_FAILED: A subnet ID or network interface ID is required to carry out the request

Hi. Thanks for the excellent blog post and this script. However I am now getting an error creating the instance:

The following resource(s) failed to create: [VPNServerInstance]. . Rollback requested by user.
--
| 18:01:07 UTC+0100 | CREATE_FAILED | AWS::EC2::Instance | VPNServerInstance | The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out the request.

It seems that

You must launch your T2 instances into a virtual private cloud (VPC); they are not supported on the EC2-Classic platform

as per http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-instances.html

mac os x sierra connection error

Hi,

My mac, running macOS 10.12.1, is unable to connect to the vpn server. "The L2TP-VPN server did not respond. Try reconnecting. If the problem continues, verify your settings and contact your administrator."

How can I debug this connectivity matter? I attempted to create a stack in two different regions and experienced the same connectivity rejection. The default VPC NACL permits inbound and outbound. What else should be verified in the aws console?

PPTP is not an option with the latest version of macOS.

Thx

screen shot 2016-12-08 at 11 07 11 pm

Cannot connect to Mumbai server over L2TP(IPSec)

I just set up my EC2 instance with your json template and tried to connect my Mac and iPhone and I get the message:

The L2TP-VPN server did not respond. Try reconnecting. If the problem continues, verify your settings and contact your Administrator.

Connecting from Windows 10 BuiltIn VPN client?

Thanks for a great solution. It's been rock-solid with my iOS and Mac OS X devices but I'm banging my head against the wall with my Win10 machine. I've tried turning of the Windows Firewall and moved to different WiFi networks but without success. Also did my best to figure out which ports to open in the firewall through rules but I may not have been using the right ones.

I'm running the Shrew VPN client and a commercial VPN service (Witopia) on the same machine and both connect successfully (to other servers). Suggestions welcomed!

Thanks,

Steve

PPTP works but L2TP/IPSec does not connect

After setup the cloud formation. I was able to successfully connect to the VPN server with pptp protocol. However when trying to use L2TP/IPsec with presharedkey. Windows VPN keeps on giving errors on can not establish connections with the server

The PPTP-VPN server did not respond.

I keep getting this error when trying to connect on the Mac:

The PPTP-VPN server did not respond. Try reconnecting. If the problem continues, verify your settings and contact your Administrator.

I also cannot connect on my Nexus 5X phone.

I am able to ping the instance, as well as log in via SSH. Just cannot connect to the VPN. Any pointers how to debug this?

Error connecting

I tried PPTP as well as IPSEC. Either way it won't connect. Redeploying/rebooting the server does not help either. I tried it on both mac and ios.

PPTP Server fails to connect with DD-WRT router VPN client

I have setup the VPN server as detailed. I have been able to connect with both ios devices and my win 10 PC, but I have failed miserably with the router VPN client.

At the heart of the issue is both the ios devices and Win 10 effectively dynamically "handshake" with the server but the DD-WRT router requires the exact parameters (and I couldn't find them anywhere). I have looked at the template you provided (thank you) but there are a number of settings I am unsure of:

vpn

As you can see with the attached image I know :

  1. the server IP.
  2. Looking at the template I assume the Remote Subnet is the server IP of 10.0.0.1 but not sure, with the Remote Subnet Mask 255.255.255.255 (but the client will not allow me to save this config)
  3. Unsure whether I need to insist on mppe. (I can see when my win10 client connects its at MPPE 128. So, while I have items inthe MPPE Encryption box, unsure if I should and have tried with and without.
  4. MTU in the template is 1280
  5. MRU in the template is 1280
  6. Assume I need to enable NAT (although not sure)
  7. I know my username and pwd
  8. Additional PPTP options: not sure?

Any help you can give me in filling in the details would be great. Many thanks

Cannot deploy template in Mumbai (ap-south)

I tried deploying the template to Mumbai, but that failed.

Error:

Template validation error: Template error: Unable to get mapping for AWSRegionArch2AMI::ap-south-1::HVM64

L2TP does not persist for Apple iOS VPN

Love the article, and really appreciate the fact that you've provided updates to it as things have changed (i.e., loss of support for PPTP from Apple iOS).

I have set up L2TP VPN for a few Apple devices. It works great when connected, but the VPN connections do not persist - meaning: if I set my iPhone aside for a while, the VPN drops and I have to reconnect it manually when I go to use the iPhone again.

The upside is that it makes me pay close attention to my VPN icon at the top of the screen, so my situational awareness is high, but the downside is, "what if I forget?".

Any ideas on implementing workarounds for persistence that won't be complete resource hogs?

Server stops responding after a day or so

I've been using this setup for a few months without incident, however over the last few days I've run into a situation where I have to rebuild the server every 24 hours or so. I haven't made any changes to the server, it just stops responding and the only thing that seems to work is blowing the server away and rebuilding from scratch. Any idea as to why this might be?

"The L2TP-VPN server did not respond. Try reconnecting. If the problem continues, verify your settings and contact your Administrator."

No longer working

Hi, i was using your vpn for 3 days now but yesterday they stopped working i don't know why.
i tried to reconfigure it multiple time without success

Does not work with Lono 4

Similar to #48, this codebase does not appear to work with Lono 4:

▶ lono generate
Generating CloudFormation templates, parameters, and scripts
ERROR: The config/settings.yml does not exist in this project.  Are you sure you are in lono project?

▶ lono --version
4.0.6

Should we pin the version to the last version of Lono 3.x (3.5.0) or it may also be simple to upgrade this module to work with Lono 4 via the lono upgrade4 command. I know very little about Lono or Ruby so I'm hesitant to try to fix it myself.

Problem connecting a TL-WR941ND router

Hello
I managed to create the instance quickly as well as connecting to it form windows.
I also tried it from my Android device and it connects. Please note that once connected the internet is not accessible. Looking at the IP config I see that the gateway is set to 0.0.0.0.

When choosing PPTP on my router and providing the same user/psw it does NOT connect.

Any idea what could be the issue? Could it be related to the IPSEC? There is no place to provide it in my router setting.

Thanks,
Mickey.

Question Setting Up VPN w/ Fail2Ban IPTable Rules

Hey there!

Enjoyed the Youtube video and the article on how to get this setup. Instead of opting for a brand new VM, I attempted to follow your script on an existing VPN. I'm having issues connecting and I believe it has something to do with iptables.

My current script I used to setup my rules is:

#!/bin/sh
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

# FTP
iptables -A INPUT -p tcp --dport 20:21 -j ACCEPT
iptables -A INPUT -p tcp --dport 989:990 -j ACCEPT

# SSH
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Reroute HTTP to 9000 and HTTPS to 9001
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 9000
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 9001

# HTTP
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 5984 -j ACCEPT
iptables -A INPUT -p tcp --dport 9000 -j ACCEPT

# FTP Passive Ports
iptables -A INPUT -p tcp --dport 13000:13100 -j ACCEPT

# Route VPN connections
iptables -t nat -A POSTROUTING -s 192.168.42.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# Drop rest
iptables -A INPUT -j DROP

# Restart Fail2ban
service fail2ban restart

On this box, I've got a web server on 80/443, FTPS on 990, and now pptpd on 1723. My Amazon Policy rules are:
Policy Rules

What could possibly be causing the connection issues? Do you see anything wrong with the policies or the iptables?

I've attempted to log the data from the server and I'm not getting any logs being created.

On the client I get PPTP connect errno = 60 Operation timed out

Thanks!

Edit: Found some logs in the syslog file

Mar 26 23:28:26 ip-172-31-22-92 xl2tpd[2085]: network_thread: select returned error 4 (Interrupted system call)
Mar 26 23:28:26 ip-172-31-22-92 xl2tpd[2085]: death_handler: Fatal signal 15 received
Mar 26 23:28:27 ip-172-31-22-92 xl2tpd[2549]: setsockopt recvref[30]: Protocol not available
Mar 26 23:28:27 ip-172-31-22-92 xl2tpd[2549]: This binary does not support kernel L2TP.
Mar 26 23:28:27 ip-172-31-22-92 xl2tpd[2550]: xl2tpd version xl2tpd-1.3.6 started on ip-172-31-22-92 PID:2550
Mar 26 23:28:27 ip-172-31-22-92 xl2tpd[2550]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.
Mar 26 23:28:27 ip-172-31-22-92 xl2tpd[2550]: Forked by Scott Balmos and David Stipp, (C) 2001
Mar 26 23:28:27 ip-172-31-22-92 xl2tpd[2550]: Inherited by Jeff McAdams, (C) 2002
Mar 26 23:28:27 ip-172-31-22-92 xl2tpd[2550]: Forked again by Xelerance (www.xelerance.com) (C) 2006
Mar 26 23:28:27 ip-172-31-22-92 xl2tpd[2550]: Listening on IP address 0.0.0.0, port 1701
Mar 26 23:28:39 ip-172-31-22-92 pptpd[2571]: MGR: connections limit (100) reached, extra IP addresses ignored
Mar 26 23:28:39 ip-172-31-22-92 pptpd[2572]: MGR: Manager process started
Mar 26 23:28:39 ip-172-31-22-92 pptpd[2572]: MGR: Maximum of 100 connections available
Mar 26 23:28:51 ip-172-31-22-92 ipsec_setup: Stopping Openswan IPsec...
Mar 26 23:28:52 ip-172-31-22-92 kernel: [8565537.364416] NET: Unregistered protocol family 15
Mar 26 23:28:52 ip-172-31-22-92 ipsec_setup: ...Openswan IPsec stopped
Mar 26 23:28:52 ip-172-31-22-92 kernel: [8565537.391134] NET: Registered protocol family 15
Mar 26 23:28:52 ip-172-31-22-92 ipsec_setup: Starting Openswan IPsec U2.6.38/K3.13.0-36-generic...
Mar 26 23:28:52 ip-172-31-22-92 ipsec_setup: Using NETKEY(XFRM) stack
Mar 26 23:28:52 ip-172-31-22-92 kernel: [8565537.434369] Initializing XFRM netlink socket
Mar 26 23:28:52 ip-172-31-22-92 kernel: [8565537.447638] AVX2 instructions are not detected.
Mar 26 23:28:52 ip-172-31-22-92 kernel: [8565537.456706] AVX2 or AES-NI instructions are not detected.
Mar 26 23:28:52 ip-172-31-22-92 ipsec_setup: ...Openswan IPsec started
Mar 26 23:28:52 ip-172-31-22-92 ipsec__plutorun: adjusting ipsec.d to /etc/ipsec.d
Mar 26 23:28:52 ip-172-31-22-92 pluto: adjusting ipsec.d to /etc/ipsec.d
Mar 26 23:28:52 ip-172-31-22-92 ipsec__plutorun: 002 added connection description "vpnpsk"

Web hosting from behind this VPN

I have been trying to make my server (IIS) reachable from the outside, with my domain name directed to my AWS IP. I have my WRT54g set up as my client gateway and a computer running a VM with a bridged NIC is attached to it with full internet connectivity. I have added security policies for HTTP/S in AWS and port forwarding anywhere else applicable. I realize now this VPN isn't like one in the VPC on AWS, so I don't know how to set up any routing (if needed). Please help!!

Can we use multiple account on it?

It seems that I can only set single VPN connection account on it. Is there any way to set up more account? And I do not know the ubuntu system account's password....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.