CentOS 6、7下pptp 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

pptp_install.png

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

  1. #!/bin/bash

  2. #

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

  4. # 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 //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://linuxeye.com/

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

关于软件资源类分享的免责声明:
本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并未做任何贩卖软件信息等行为,不存在任何商业目的及用途。
根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。"
您需知晓本站所有分享内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任。
如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇