当前位置:   article > 正文

云服务器搭建pptd_centos 7安装pptd

centos 7安装pptd

版本选型

  • 这里选型Centos 7.2

操作:

  • 查看当前系统版本
  1. cat /etc/redhat-release
  • 安装相应的软件包,这里ppp、pptpd、iptables、iptables-service都要安装
  1. a)centos版本小于7,安装以下软件
  2. yum -y install ppp pptpd iptables
  3. b)centos版本大于7,还需额外安装一下软件
  4. <https://www.notion.so/VPN-7fc4d404fa2d4b99b650d2351daa54d8>
  5. yum update iptables
  6. yum -y install iptables iptables-services
  • 配置pptpd服务

    1. 配置pptpd服务ip,取消默认文件localip、remoteip前的#,也可自行设置。主要用于服务地址及客户端地址配置,客户端地址在后面配置防火墙策略至关重要

      1. vi /etc/pptpd.conf
      2. # (Recommended)
      3. localip 192.168.0.1#(固定写法)
      4. remoteip 192.168.0.100-109,192.168.0.245#(固定写法)
      5. # or
      6. #localip 192.168.0.234-238,192.168.0.245
      7. #remoteip 192.168.1.234-238,192.168.1.245
    2. 配置ppp中DNS,增加8.8.8.8、8.8.4.4 GoogleDNS

      1. vi /etc/ppp/options.pptpd
      2. 修改后(此处只截取了部分)
      3. #ms-dns 10.0.0.1
      4. #ms-dns 10.0.0.2
      5. ms-dns 8.8.8.8
      6. ms-dns 8.8.4.4
    3. 配置客户端用户

      1. vi /etc/ppp/chap-secrets
      2. 修改后,分别为用户名、服务、密码、ip。(ip为 " * " 则代表所有ip均可访问)
      3. # Secrets for authentication using CHAP
      4. # client server secret IP addresses
      5. root pptpd root *
    4. 开启内核转发

      1. #查看内核配置(此处主要作用于修改内核转发)
      2. cat /etc/sysctl.conf
      3. #修改为允许转发(默认=0),如果没有自行添加即可
      4. net.ipv4.ip_forward=1
      • 生效

        sysctl -p
        
    5. 配置防火墙策略

      1. #查看防火墙当前配置
      2. iptables -L -n
      3. #允许所有请i去
      4. iptables -P INPUT ACCEPT
      5. # 清空默认所有规则
      6. iptables -F
      7. # 清空自定义所有规则
      8. iptables -X
      9. # 计数器置0
      10. iptables -Z
      11. # 允许127.0.0.1访问本地服务
      12. iptables -A INPUT -i lo -j ACCEPT
      13. # 允许访问外部服务
      14. iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
      15. # 允许 ping
      16. iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
      17. # 开启 ssh 端口
      18. iptables -A INPUT -p tcp --dport 22 -j ACCEPT
      19. # 开启 pptpd 端口
      20. iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
      21. #配置转发策略 192.168.0.* 到 MASQUERADE(会自动判断公网IP)
      22. iptables -A POSTROUTING -t nat -s 192.168.0.0/24 -o eth0 -j MASQUERADE
      • Tips:此处需要注意,我购置的ECS为专有网络,开通了公网弹性IP,但是ifconfig下是只有一块内网网卡显示。网上很多教程会有说明阿里云的服务器是双网卡,要修改成eth1,经过翻来覆去测试均已失败告终。此处我用了内网网卡eth0,搭建成功。
    6. 保存并测试

      1. #保存iptables配置
      2. service iptables save 或者 /etc/init.d/iptables save
      3. iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
      4. #重启iptables服务
      5. service iptables restart 或者 /etc/init.d/iptables restart
      6. #重启pptpd服务,如果提示需要restart-kill,执行即可
      7. service pptpd restart 或者 /etc/init.d/pptpd restart
    7. 设置开机自启

      1. # 开机启动 iptables
      2. systemctl enable iptables.service
      3. # 开机启动 pptpd
      4. systemctl enable pptpd.service
    • 切记如果是阿里云的云服务器需要在安全组配置1723端口对外开放规则,否则将无法连接
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/860584
推荐阅读
相关标签
  

闽ICP备14008679号