Skip to content

Instantly share code, notes, and snippets.

@Zenuncl
Created November 19, 2014 17:51
Show Gist options
  • Save Zenuncl/f50b89e7211a280d8fe9 to your computer and use it in GitHub Desktop.
Save Zenuncl/f50b89e7211a280d8fe9 to your computer and use it in GitHub Desktop.
PPTP VPN 安装脚本
#!/bin/bash
type pptpd > /dev/null 2>&1
[ $? -ne 0 ] && apt-get install pptpd
grep '^localip 192.168.' /etc/pptpd.conf > /dev/null
if [ $? -ne 0 ]; then
cat >> /etc/pptpd.conf <<PPTPDCONF
localip 192.168.17.1
remoteip 192.168.17.11-60
PPTPDCONF
fi
grep '^ms-dns 8.8.8.8' /etc/ppp/options > /dev/null
if [ $? -ne 0 ]; then
cat >> /etc/ppp/options <<PPPOPTIONS
ms-dns 8.8.8.8
ms-dns 8.8.4.4
PPPOPTIONS
fi
echo -n "设置您的VPN账号的用户名: "
read username
echo -n "为您的VPN账号设置密码: "
read password
cat >> /etc/ppp/chap-secrets <<SECRETS
$username pptpd $password *
SECRETS
sed -i 's/#\(net\.ipv4\.ip_forward=1\)/\1/g' /etc/sysctl.conf
/sbin/sysctl -p
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sed -i "s/exit 0/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE\nexit 0/g" /etc/rc.local
/etc/init.d/pptpd restart
echo "PPTP VPN 安装完毕,请使用以下账户登录:"
echo "用户名: $username"
echo "密码: $password"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment