自动安装脚本如下:

#cat vpn_pptpd.sh

#!/bin/sh
export LANG=C
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
blue=`echo -e "\033[0;36;2m"`
white=`echo -e "\033[40;37m"`
ip=`netstat -ntlpa | grep sshd | grep -v LISTEN | awk '{print $4}' awk -F ":" '{print $1}'`
eth=`ip a | grep $ip | awk '{print $NF}'|tail -n1`
install_vpn(){
        echo $blue
        echo "start install vpn for pptpd......"
        echo $white
        sleep 5
    rpm -qa | grep pptpd > /dev/null
    if [ $? -eq 0 ];then
        echo "svn pptpd Already installed"
        exit
    else
            yum install pptpd -y
            pptpd_conf
            vpn_conf
            vpn_pass
            sed -i 's/exit 0/ifconfig $1 mtu 1496\nexit 0/g' /etc/ppp/ip-up
            echo 1 > /proc/sys/net/ipv4/ip_forward
            /sbin/iptables -t nat -A POSTROUTING -o $eth -j MASQUERADE
    fi
}
 
#配置文件IP地址范围
pptpd_conf(){
cat /etc/pptpd.conf << EOF
option /etc/ppp/options.pptpd
localip 192.168.12.1
remoteip 192.168.12.10-60
EOF
}
 
#配置认证方式和DNS
vpn_conf(){
cat /etc/ppp/options.pptpd << EOF
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
proxyarp
lock
EOF
}
 
#配置用户名密码
vpn_pass(){
cat /etc/ppp/chap-secrets << EOF
test pptpd test *
EOF
}
auto_start(){
chkconfig pptpd on
cat /etc/rc.local << EOF
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o $eth -j MASQUERADE
EOF
}
install_status(){
        /etc/init.d/pptpd start
        netstat -ntlp | grep pptpd
        if [ $? -eq 0 ];then
        echo $blue
        echo "---------------------------------"
        echo "vpn for pptpd install success"
        echo "ip:$ip"
        echo "port:1723"
        echo "user:test"
        echo "pass:test"
        echo "---------------------------------"
        echo $white
        auto_start
        else
                echo $blue
                echo "vpn for pptpd install error"
                echo $white
    fi
}
#VPN 安装
grep aliyun /etc/yum.repos.d/CentOS-Base.repo > /dev/null
if [ $? -eq 0 ];then
    echo $blue
    echo "Use aliyun yum.repos"
    echo $white
    install_vpn
    install_status
else
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    cd /etc/yum.repos.d
    wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
    yum clean all
    sleep 3
    yum makecache
    sleep 3
    install_vpn
    install_status

fi

iptables


iptables -A INPUT -p tcp --dport 1723 -j ACCEPT

iptables -A INPUT -p gre -j ACCEPT