IT俱乐部-城北日常经验分享

浏览: 5393    评论: 0

转发 CentOS 6、7下pptp vpn一键安装脚本,安装起来十分方便简单。正常情况下两分钟就安装好可以正常使用!!!

关键命令:

  1. wget http://mirrors.linuxeye.com/scripts/vpn_centos.sh

  2. chmod +x ./vpn_centos.sh

  3. ./vpn_centos.sh

就这三句。然后输入VPN的帐号 密码就完事了。很简单,十分适应像城北一样的新手。菜鸟收藏备用吧!


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

  1. wget http://mirrors.linuxeye.com/scripts/vpn_centos.sh

  2. chmod +x ./vpn_centos.sh

  3. ./vpn_centos.sh

linxu CentOS 6、7下pptp vpn一键安装包脚本 包成功新手收藏必备


可以自己 把文件下载去修改,但关键的地方不建议修改,改错了麻烦除非你是大神。


脚本内容如下(vpn_centos.sh):

  1. #!/bin/bash

  2. #

  3. # Author:  yeho <lj2007331 AT gmail.com>

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

  5. #

  6. # Installs a PPTP VPN-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 VPN-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. VPN_IP=`curl ipv4.icanhazip.com`


  20. VPN_USER="linuxeye"

  21. VPN_PASS="linuxeye"


  22. VPN_LOCAL="192.168.0.150"

  23. VPN_REMOTE="192.168.0.151-200"



  24. while :; do echo

  25.     read -p "Please input username: " VPN_USER

  26.     [ -n "$VPN_USER" ] && break

  27. done


  28. while :; do echo

  29.     read -p "Please input password: " VPN_PASS

  30.     [ -n "$VPN_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 's@net.ipv4.ip_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 $VPN_LOCAL" >> /etc/pptpd.conf # Local IP address of your VPN server

  67. [ -z "`grep '^remoteip' /etc/pptpd.conf`" ] && echo "remoteip $VPN_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 "$VPN_USER pptpd $VPN_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 VPN via your external IP \033[32m${VPN_IP}\033[0m"


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

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

以上文件是参考:https://github.com/drewsymo/VPN  所做修改得来的。


全文详见:http://it-club.cn/post/58.html

TOP

评论列表


发表评论
来宾的头像

TOP

网站分类

TOP

站点信息

  • 文章总数:738
  • 页面总数:1
  • 分类总数:3
  • 标签总数:24
  • 评论总数:270
  • 浏览总数:10021107