CentOS 6、7下pptp ***一键安装脚本,安装如下:

  1. wget http://mirrors.linuxeye.com/scripts/***_centos.sh

  2. chmod +x ./***_centos.sh

  3. ./***_centos.sh

d8596662-3c70-46e8-8833-582322ca64b8

脚本内容如下(***_centos.sh):

  1. #!/bin/bash

  2. #

  3. # Author:  yeho

  4. # Blog:  //blog.linuxeye.com

  5. #

  6. # Installs a PPTP ×××-only system for CentOS


  7. # Check if user is root

  8. [ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; }


  9. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

  10. clear

  11. printf "

  12. #######################################################################

  13. #    LNMP/LAMP/LANMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+    #

  14. #            Installs a PPTP ×××-only system for CentOS               #

  15. # For more information please visit //blog.linuxeye.com/31.html  #

  16. #######################################################################

  17. "


  18. [ ! -e '/usr/bin/curl' ] && yum -y install curl


  19. ×××_IP=`curl ipv4.icanhazip.com`


  20. ×××_USER="linuxeye"

  21. ×××_PASS="linuxeye"


  22. ×××_LOCAL="192.168.0.150"

  23. ×××_REMOTE="192.168.0.151-200"



  24. while :; do echo

  25.     read -p "Please input username: " ×××_USER

  26.     [ -n "$×××_USER" ] && break

  27. done


  28. while :; do echo

  29.     read -p "Please input password: " ×××_PASS

  30.     [ -n "$×××_PASS" ] && break

  31. done

  32. clear



  33. if [ -f /etc/redhat-release -a -n "`grep ' 7\.' /etc/redhat-release`" ];then

  34.     #CentOS_REL=7

  35.     if [ ! -e /etc/yum.repos.d/epel.repo ];then

  36.         cat > /etc/yum.repos.d/epel.repo << EOF

  37. [epel]

  38. name=Extra Packages for Enterprise Linux 7 - \$basearch

  39. #baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch

  40. mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch

  41. failovermethod=priority

  42. enabled=1

  43. gpgcheck=0

  44. EOF

  45.     fi

  46.     for Package in wget make openssl gcc-c++ ppp pptpd iptables iptables-services

  47.     do

  48.         yum -y install $Package

  49.     done

  50.     echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf

  51. elif [ -f /etc/redhat-release -a -n "`grep ' 6\.' /etc/redhat-release`" ];then

  52.     #CentOS_REL=6

  53.     for Package in wget make openssl gcc-c++ iptables ppp

  54.     do

  55.         yum -y install $Package

  56.     done

  57.     sed -i '[email protected]_forward.*@net.ipv4.ip_forward = 1@g' /etc/sysctl.conf

  58.     rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm

  59.     yum -y install pptpd

  60. else

  61.     echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m"

  62.     exit 1

  63. fi


  64. echo "1" > /proc/sys/net/ipv4/ip_forward


  65. sysctl -p /etc/sysctl.conf


  66. [ -z "`grep '^localip' /etc/pptpd.conf`" ] && echo "localip $×××_LOCAL" >> /etc/pptpd.conf # Local IP address of your ××× server

  67. [ -z "`grep '^remoteip' /etc/pptpd.conf`" ] && echo "remoteip $×××_REMOTE" >> /etc/pptpd.conf # Scope for your home network


  68. if [ -z "`grep '^ms-dns' /etc/ppp/options.pptpd`" ];then

  69.      cat >> /etc/ppp/options.pptpd << EOF

  70. ms-dns 223.5.5.5 # Aliyun DNS Primary

  71. ms-dns 114.114.114.114 # 114 DNS Primary

  72. ms-dns 8.8.8.8 # Google DNS Primary

  73. ms-dns 209.244.0.3 # Level3 Primary

  74. ms-dns 208.67.222.222 # OpenDNS Primary

  75. EOF

  76. fi


  77. echo "$×××_USER pptpd $×××_PASS *" >> /etc/ppp/chap-secrets


  78. ETH=`route | grep default | awk '{print $NF}'`

  79. [ -z "`grep '1723 -j ACCEPT' /etc/sysconfig/iptables`" ] && iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 1723 -j ACCEPT

  80. [ -z "`grep 'gre -j ACCEPT' /etc/sysconfig/iptables`" ] && iptables -I INPUT 5 -p gre -j ACCEPT

  81. iptables -t nat -A POSTROUTING -o $ETH -j MASQUERADE

  82. iptables -I FORWARD -p tcp --syn -i ppp+ -j TCPMSS --set-mss 1356

  83. service iptables save

  84. sed -i 's@^-A INPUT -j REJECT --reject-with icmp-host-prohibited@#-A INPUT -j REJECT --reject-with icmp-host-prohibited@' /etc/sysconfig/iptables

  85. sed -i 's@^-A FORWARD -j REJECT --reject-with icmp-host-prohibited@#-A FORWARD -j REJECT --reject-with icmp-host-prohibited@' /etc/sysconfig/iptables

  86. service iptables restart

  87. chkconfig iptables on


  88. service pptpd restart

  89. chkconfig pptpd on

  90. clear


  91. echo -e "You can now connect to your ××× via your external IP \033[32m${×××_IP}\033[0m"


  92. echo -e "Username: \033[32m${×××_USER}\033[0m"

  93. echo -e "Password: \033[32m${×××_PASS}\033[0m"

参考:https://github.com/drewsymo/×××