Skip to content

Instantly share code, notes, and snippets.

@harmy
Created October 15, 2012 07:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save harmy/3891178 to your computer and use it in GitHub Desktop.
Save harmy/3891178 to your computer and use it in GitHub Desktop.
Ubuntu VPN for poor Chinese (on AWS EC2)
#!/bin/bash -x
## original author: Oliver Nassar <onassar@gmail.com>
## credit: harmy <hack4cn@gmail.com>
## Ubuntu VPN for poor Chinese (you know de)
## Sample Usage:
##
## wget https://gist.github.com/raw/3891178/ff1702fac175eb21c513b93f51f39948be693aba/vpn-setup.sh
## chmod +x vpn-setup.sh
## sudo ./vpn-setup.sh <username> <password>
## 0.1 Username/Password Check
## Checks to make sure *2* parameters were specified
##
if [ $# -ne 2 ]
then
echo "Usage: sudo ./`basename $0` <username> <password>"
exit 0
fi
USERNAME=$1
PASSWORD=$2
## 1.0 VPN Setup
##
##
sudo apt-get -y install pptpd
echo "ms-dns 8.8.8.8" | sudo tee -a /etc/ppp/options
echo "ms-dns 8.8.4.4" | sudo tee -a /etc/ppp/options
echo "$USERNAME pptpd $PASSWORD *" | sudo tee -a /etc/ppp/chap-secrets
sudo perl -0 -p -i -e 's/\n#net.ipv4.ip_forward=1/\nnet.ipv4.ip_forward=1/' /etc/sysctl.conf
sudo sysctl -p
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo perl -0 -p -i -e 's/\nexit 0/\n\n# <build script modifications>\n \sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE\n# <\/build script modifications>\n\nexit 0/' /etc/rc.local
sudo /etc/init.d/pptpd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment