网站目录收录网站方式:1.人工手动审核。2.自助审核(你的网站在权重3、PR4以上,挂上本站友链->点击友链->自动审核通过。)
北京 天津 上海 广东 深圳 河北 河南 新疆 重庆 四川 贵州 湖南 湖北 云南 广西 宁夏 青海 甘肃 陕西
西藏 海南 山东 福建 安徽 浙江 吉林 山西 江西 江苏 辽宁 黑龙 内蒙 澳门 香港 台湾 日本 韩国 美国
当前位置:站长啦网站目录 » 新闻资讯 » 站长新闻 » 技术文档 » 文章详细 订阅RssFeed

[VPN]linux下一键安装VPN,CentOS 6、7一键安装PPTP VPN及解决不能访问外网的方法

来源:CentOS 6、7一键安装PPTP VPN 浏览:2772次 时间:2020-03-27
简介:[VPN]linux下一键安装VPN,CentOS 6、7一键安装PPTP VPN及解决不能访问外网的方法 CentOS 6、7下 VPN一键安装脚本pptp,一键安装PPTP VPN 还有解决Linux下PPTPD搭建VPN服务器连接后无法上外网解决办法


[VPN]linux下一键安装VPN,CentOS 6、7一键安装PPTP VPN及解决不能访问外网的方法

pptp,并已经添加到《lnmp一键安装包》。这个脚本可以单独使用,直接复制或下载执行即可,不用依赖安装包的其它脚本。

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

  1. wget http://mirrors.linuxeye.com/scripts/vpn_centos.sh
  2. chmod +x ./vpn_centos.sh
  3. ./vpn_centos.sh
CentOS 6、7下pptp vpn一键安装脚本

脚本内容如下(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://github.com/drewsymo/VPN




Linux下PPTPD搭建VPN服务器连接后无法上外网解决办法

1.、请确保你的MS-DNS和防火墙已经正确配置:

防火墙按照下面方法配置:

1
2
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source 你的公网IP
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

若出现无法连接,可以尝试按照上面解决619错误的设置方法设置

编辑/etc/ppp/options.pptpd:

1
vi /etc/ppp/options.pptpd

去掉ms-dns前面的#,并修改成如下字段:

1
2
ms-dns 8.8.8.8
ms-dns 8.8.4.4

2、编辑/etc/sysctl.conf

将“net.ipv4.ip_forward”改为1

同时在“net.ipv4.tcp_syncookies = 1”前面加#

3、执行下面的命令

1
sysctl -p

4、如此执行后,应该可以正常连接外网了。



0

版权与免责声明:

凡注明稿件来源的内容均为转载稿或由网友用户注册发布,本网转载出于传递更多信息的目的;如转载稿涉及版权问题,请作者联系我们,同时对于用户评论等信息,本网并不意味着赞同其观点或证实其内容的真实性;


本文地址:https://top.cnzzla.com/artinfo/49886.html

好玩的手游下载

猜你喜欢

推荐站点

  • 福州小程序开发福州小程序开发

    福州好小蚁科技提供专业的微信小程序开发、软件定制、手机APP开发、网站开发等高端定制外包服务,价格美丽,服务周到.一对一项目对接,不满意退全款!预约电话:13107632710 胡小春!福州好小蚁科技有限公司是福建福州网站app等技术开发优秀网络公司。

    www.fzant.com
  • 世界时间网世界时间网

    世界时间网为您提供世界各地精准时间,北京时间校准器,标准时间,世界各地时间与北京时间对比,时间换算等,希望对您有所帮助。

    top.cnzzla.com/time
  • 科技镇科技镇

    科技镇 | 关注科技、娱乐、人文、生活!

    www.kejizhen.com
  • 心动网址导航心动网址导航

    心动网址导航精选了国内国外著名的网站、好玩的、好看的、有趣的国内国外网站以及实用的、优秀的国内国外网站,包括国外视频、国外购物、国外交友、国外新闻等多种类型 同时提供精品行业分类目录提交,让用户全方位了解国内国外互联网动态!

    xd00.com
  • 门户网址-优秀网站导航门户网址-优秀网站导航

    门户网址-优秀网站导航,精选网址导航,免费分类目录提交,实用酷站大全。

    top.mhwz.cn

最新优秀网站