Skip to content

Instantly share code, notes, and snippets.

@erlhermit
Created July 14, 2015 19:08
Show Gist options
  • Save erlhermit/69a2c2f3d3ff0a863aea to your computer and use it in GitHub Desktop.
Save erlhermit/69a2c2f3d3ff0a863aea to your computer and use it in GitHub Desktop.
vpn_pptp_debian.sh
#!/bin/bash
function installVPN(){
apt-get update
#remove ppp pptpd
rm -rf /etc/pptpd.conf
rm -rf /etc/ppp
apt-get -y remove ppp pptpd
apt-get -y install ppp pptpd iptables
echo ms-dns 8.8.8.8 >> /etc/ppp/pptpd-options
echo ms-dns 8.8.4.4 >> /etc/ppp/pptpd-options
echo localip 192.168.99.1 >> /etc/pptpd.conf
echo remoteip 192.168.99.9-99 >> /etc/pptpd.conf
iptables -t nat -A POSTROUTING -s 192.168.99.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0' | cut -d: -f2 | awk 'NR==1 { print $1}'`
sed -i 's/exit\ 0/#exit\ 0/' /etc/rc.local
echo iptables -t nat -A POSTROUTING -s 192.168.99.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0' | cut -d: -f2 | awk 'NR==1 { print $1}'` >> /etc/rc.local
echo exit 0 >> /etc/rc.local
echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
sysctl -p
echo user1 pptpd user1 \* > /etc/ppp/chap-secrets
echo user2 pptpd user2 \* >> /etc/ppp/chap-secrets
echo user3 pptpd user3 \* >> /etc/ppp/chap-secrets
echo user4 pptpd user4 \* >> /etc/ppp/chap-secrets
echo user5 pptpd user5 \* >> /etc/ppp/chap-secrets
/etc/init.d/pptpd restart
}
function repaireVPN(){
echo "begin to repaire VPN";
mknod /dev/ppp c 108 0
/etc/init.d/pptpd restart
}
function addVPNuser(){
echo "input user name:"
read username
echo "input password:"
read userpassword
echo "${username} pptpd ${userpassword} *" >> /etc/ppp/chap-secrets
/etc/init.d/pptpd restart
}
echo "which do you want to?input the number."
echo "1. install VPN service"
echo "2. repaire VPN service"
echo "3. add VPN user"
read num
case "$num" in
[1] ) (installVPN);;
[2] ) (repaireVPN);;
[3] ) (addVPNuser);;
*) echo "nothing,exit";;
esac
@erlhermit
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment