Skip to content

Instantly share code, notes, and snippets.

@ychin
Last active February 4, 2018 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ychin/8851062 to your computer and use it in GitHub Desktop.
Save ychin/8851062 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Original steps from: http://www.yzhang.net/blog/2013-03-07-pptp-vpn-ec2.html
#
# Run this in a root bash environment. This assumes a setting similar to Amazon EC2 Linux.
# Otherwise replace the lines that start with "yum" with whatever package manager is used.
# The script will ask for username and password, but if you want to do this programmatically,
# you can set environment variables $vpn_username and $vpn_password, then run with --no-prompt.
#
# After this is all set you should be able to connect to your new machine using VPN. Make
# sure to pick PPTP as the protocol, and use the username/password you have selected.
if [ "$1" != "--no-prompt" ]
then
echo -n "Username: "
read vpn_username
echo -n "Password: "
read -s vpn_password
echo
fi
yum -y update
wget http://poptop.sourceforge.net/yum/stable/rhel6/x86_64/pptpd-1.4.0-1.el6.x86_64.rpm
yum -y localinstall pptpd-1.4.0-1.el6.x86_64.rpm
echo localip 192.168.9.1 >> /etc/pptpd.conf
echo remoteip 192.168.9.11-30 >> /etc/pptpd.conf
echo ms-dns 8.8.8.8 >> /etc/ppp/options.pptpd
echo ms-dns 8.8.4.4 >> /etc/ppp/options.pptpd
echo "$vpn_username pptpd $vpn_password *" >> /etc/ppp/chap-secrets
echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
/sbin/sysctl -p
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE" >> /etc/rc.local
/sbin/service pptpd start
chkconfig pptpd on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment