Skip to content

Instantly share code, notes, and snippets.

@yinhm
Created July 12, 2012 07:50
Show Gist options
  • Save yinhm/3096525 to your computer and use it in GitHub Desktop.
Save yinhm/3096525 to your computer and use it in GitHub Desktop.
pptpd for Debian
# Automaticlly install pptpd on Debian Linux
#
# Ripped from http://blog.diahosting.com/linux-tutorial/pptpd/
# pptpd source rpm packing by it's authors
#
# Authors: yinhm
# Version: 0.1.0
# URL: http://yinhm.appspot.com/
apt-get -y update
apt-get -y upgrade
apt-get remove -y pptpd ppp
iptables --flush POSTROUTING --table nat
iptables --flush FORWARD
rm -rf /etc/pptpd.conf
rm -rf /etc/ppp
apt-get -y install ppp pptpd
sed -i 's/^net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
sysctl -p
echo "localip 192.168.240.1" >> /etc/pptpd.conf
echo "remoteip 192.168.240.2-100" >> /etc/pptpd.conf
echo "ms-dns 8.8.8.8" >> /etc/ppp/options.pptpd
pass=`openssl rand 8 -base64`
if [ "$1" != "" ]
then pass=$1
fi
echo "vpn pptpd ${pass} *" >> /etc/ppp/chap-secrets
iptables -t nat -A POSTROUTING -s 192.168.240.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==1 { print $1}'`
iptables -A FORWARD -p tcp --syn -s 192.168.240.0/24 -j TCPMSS --set-mss 1356
iptables-save > /etc/iptables.up.rules
cat >>/etc/network/if-pre-up.d/iptables<<EOF
#!/bin/bash
/sbin/iptables-restore < /etc/iptables.up.rules
EOF
chmod +x /etc/network/if-pre-up.d/iptables
#chkconfig pptpd on
/etc/init.d/pptpd restart
echo -e "VPN service is installed, your VPN username is \033[1mvpn\033[0m, VPN password is \033[1m${pass}\033[1m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment