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

  • Post author:
  • Post category:其他


一、环境准备

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/pptpd.conf

将#号去掉,或自行配置

配置dns

vi /etc/ppp/options.pptpd

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

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

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

vi /etc/ppp/chap-secrets

格式为

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

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

vi /etc/sysctl.conf

将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/rc.d/rc.local保存上面的命令,这样开机会自动执行上面的命令。

8.开机自启

chkconfig pptpd on#开机自启
systemctl restart pptpd#重启

三、使用

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

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

Plugin /usr/lib64/pptpd/pptpd-logwtmp.so loaded.
pptpd-logwtmp: $Version$
pppd options in effect:
debug           # (from /etc/ppp/options.pptpd)
logfile /var/log/pptpd.log              # (from /etc/ppp/options.pptpd)
dump            # (from /etc/ppp/options.pptpd)
plugin /usr/lib64/pptpd/pptpd-logwtmp.so                # (from command line)
require-mschap-v2               # (from /etc/ppp/options.pptpd)
refuse-pap              # (from /etc/ppp/options.pptpd)
refuse-chap             # (from /etc/ppp/options.pptpd)
refuse-mschap           # (from /etc/ppp/options.pptpd)
name pptpd              # (from /etc/ppp/options.pptpd)
remotenumber 117.136.92.127             # (from command line)
pptpd-original-ip 117.136.92.127                # (from command line)
115200          # (from command line)
lock            # (from /etc/ppp/options.pptpd)
local           # (from command line)
novj            # (from /etc/ppp/options.pptpd)
novjccomp               # (from /etc/ppp/options.pptpd)
ipparam 117.136.92.127          # (from command line)
ms-dns xxx # [don't know how to print value]            # (from /etc/ppp/options.pptpd)
proxyarp                # (from /etc/ppp/options.pptpd)
192.168.0.1:192.168.0.234               # (from command line)
nobsdcomp               # (from /etc/ppp/options.pptpd)
require-mppe-128                # (from /etc/ppp/options.pptpd)
using channel 22
Using interface ppp0
Connect: ppp0 <--> /dev/pts/4
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth chap MS-v2> <magic 0x273a897f> <pcomp> <accomp>]
LCP: timeout sending Config-Requests
Connection terminated.
Modem hangup



版权声明:本文为qq_40657585原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。