CentOS7.7使用pptpd搭建服务器(配置好了,但是不能使用)

时间:2024-10-06 07:20:28

一、环境准备

1.服务器

查看系统版本

cat /etc/redhat-release

操作系统:CentOS Linux release 7.7.1908 (Core)

IP地址:122.51.8.56

2、客户端

windows10操作系统,手机端

二、服务器配置

1、确定内核是否支持mppe

modprobe ppp-compress-18 && echo good!

如果输出good!,那么支持mppe,否则需要升级内核支持mppe,自行百度。

2、检查ppp是否开启

cat /dev/ppp

 3、安装ppp和pptpd

yum install ppp && yum install pptpd

4、编写配置文件

客户端分配的内网ip段

vi /etc/

将#号去掉,或自行配置

配置dns

vi /etc/ppp/options.pptpd

 这里我用的是谷歌的dns,可以有两个,第二个是备用的,自行选择。

修改日志记录 ,方便查找错误(在文件最后)

5、添加用户登录的用户名及密码

vi /etc/ppp/chap-secrets

格式为

用户名   pptpd   密码   *      中间用tab键隔开

 

 6、修改内核参数,使服务器可以转发

vi /etc/

将net.ipv4.ip_forward=0修改为1,保存退出

sysctl -p#使内核参数生效

7.添加iptables转发规则

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE  

重启后会失效,修改/etc//保存上面的命令,这样开机会自动执行上面的命令。

8.开机自启

  1. chkconfig pptpd on#开机自启
  2. systemctl restart pptpd#重启

三、使用

使用win10自带的vpn,或者手机自带的vpn尝试连接,但是一直没有成功。

并且日志一直报这个错误。 

  1. Plugin /usr/lib64/pptpd/ loaded.
  2. pptpd-logwtmp: $Version$
  3. pppd options in effect:
  4. debug # (from /etc/ppp/options.pptpd)
  5. logfile /var/log/ # (from /etc/ppp/options.pptpd)
  6. dump # (from /etc/ppp/options.pptpd)
  7. plugin /usr/lib64/pptpd/ # (from command line)
  8. require-mschap-v2 # (from /etc/ppp/options.pptpd)
  9. refuse-pap # (from /etc/ppp/options.pptpd)
  10. refuse-chap # (from /etc/ppp/options.pptpd)
  11. refuse-mschap # (from /etc/ppp/options.pptpd)
  12. name pptpd # (from /etc/ppp/options.pptpd)
  13. remotenumber 117.136.92.127 # (from command line)
  14. pptpd-original-ip 117.136.92.127 # (from command line)
  15. 115200 # (from command line)
  16. lock # (from /etc/ppp/options.pptpd)
  17. local # (from command line)
  18. novj # (from /etc/ppp/options.pptpd)
  19. novjccomp # (from /etc/ppp/options.pptpd)
  20. ipparam 117.136.92.127 # (from command line)
  21. ms-dns xxx # [don't know how to print value] # (from /etc/ppp/)
  22. proxyarp # (from /etc/ppp/)
  23. 192.168.0.1:192.168.0.234 # (from command line)
  24. nobsdcomp # (from /etc/ppp/)
  25. require-mppe-128 # (from /etc/ppp/)
  26. using channel 22
  27. Using interface ppp0
  28. Connect: ppp0 <--> /dev/pts/4
  29. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  30. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  31. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  32. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  33. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  34. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  35. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  36. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  37. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  38. sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
  39. LCP: timeout sending Config-Requests
  40. Connection terminated.
  41. Modem hangup