Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ubuntu 11.04 AWS EC2 PPTPD Installer
#!/bin/bash
#
# This script will install and configure a PPTPD server on your Ubuntu box.
# I use this for a micro instance on Amazon EC2 as a quick, cheap (free!) VPN
#
# This script was tested with Natty Narwahl 11.04, ami-06ad526f
#
# Usage:
# wget https://gist.github.com/raw/950539/pptpd.sh
# sudo su
# /bin/bash pptpd.sh
#
# If you are running this on EC2, also make sure you have a permissive security group.
#
# Based on http://www.dikant.de/2010/10/08/setting-up-a-vpn-server-on-amazon-ec2/
#
apt-get -y install pptpd
echo "localip 192.168.240.1" >> /etc/pptpd.conf
echo "remoteip 192.168.240.2-9" >> /etc/pptpd.conf
# Google DNS, change if you like.
echo "ms-dns 8.8.8.8" >> /etc/ppp/pptpd-options
echo "ms-dns 8.8.4.4" >> /etc/ppp/pptpd-options
PASSWORD=$(echo "$RANDOM.$(date +%s)" | shasum | awk '{print $1}')
echo "vpn pptpd $PASSWORD *" >> /etc/ppp/chap-secrets
/etc/init.d/pptpd restart
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE" > /etc/rc.local
echo "exit 0" >> /etc/rc.local
echo "Installed! Your username is vpn and your password is $PASSWORD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.