温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Centos6配置PPTP连接VPS服务器

发布时间:2020-08-09 23:46:13 来源:网络 阅读:661 作者:萨瓦迪迪卡 栏目:系统运维

简述:

PPTP:点对点隧道协议

(PPTP: Point to Point Tunneling Protocol)

通过该协议,远程用户能够通过 Microsoft Windows NT 工作站、Windows 95 和 Windows

98 操作系统以及其它装有点对点协议的系统安全访问公司网络,并能拨号连入本地 ISP,通过 Internet 安全链接到公司网络。

一、安装前准备

首先检查你 VPS 的 PPP 和 TUN 有没有启用:

[root@yunwei_cq ~]# cat /dev/ppp
cat: /dev/ppp: No such device or address
[root@yunwei_cq ~]#
[root@yunwei_cq ~]#
[root@yunwei_cq ~]# cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state

显示结果为:

cat: /dev/ppp: No such device or address
cat: /dev/net/tun: File descriptor in bad state

表明通过,上述两条只要有一个没通过都不行。如果没有启用,你可以给 VPS 提供商 Submit

一个 Ticket 请求开通:

Hello

Could you enabled TUN-TAP for me? I want run pptpon my VPS.

Thank you.

确认 PPP 和 TUN 启用后,开始安装 ppp 和 iptables

二、安装 ppp 和 iptables

1.安装前检查是否已安装(本机已安装 iptables)

[root@yunwei_cq ~]# rpm -qa | grep ppp
[root@yunwei_cq ~]# rpm -qa | grep iptables
iptables-1.4.7-11.el6.x86_64
iptables-ipv6-1.4.7-11.el6.x86_64

2.安装 ppp 协议

[root@yunwei_cq yum.repos.d]# yum install -y ppp 
    Loaded plugins: fastestmirror, security
Repository base is listed more than once in the configuration Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ppp.x86_64 0:2.4.5-10.el6 will be installed --> Finished Dependency Resolution ...
三、安装 pptpd 程序

1.如果提示没有 pptpd 安装包,需要自己下载安装。

[root@yunwei_cq yum.repos.d]# yum install -y pptpd 
    Loaded plugins: fastestmirror, security
Repository base is listed more than once in the configuration Loading mirror speeds from cached hostfile Setting up Install Process
No package pptpd available.

附 rpm 安装包安装地址: https://down.51cto.com/data/2368471

2.安装 pptpd 服务

[root@yunwei_cq packages]# rpm -ivh pptpd-1.3.4-2.el6.x86_64.rpm
warning: pptpd-1.3.4-2.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 862acc42:
NOKEY
Preparing...
1:pptpd
########################################### [100%]
########################################### [100%]

四、修改配置文件

1.vim /etc/pptpd.conf

option /etc/ppp/options.pptpd   ##配置文件路径
logwtmp ##日志
localip xxxxxxxxx   ## 填写远程服务器的外网地址
remoteip 192.168.101.1-50   ## 给一个分配给连接的客户机的 IP 地址范围。

2、vim /etc/ppp/options.pptpd

name pptpd  ##设置名称
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
ms-dns 114.114.114.114  ##修改 DNS 地址
ms-dns 8.8.8.8  ##备用地址

3、vim /etc/ppp/chap-secrets

# Secrets for authentication using CHAP
# client server secret IP addresses ## client 客户端(用户名)server(服务器主机名) secret 加密密码(密码) ip ## addresses (远程主机设置固定 ip 地址)
"hongkun"   *   "test"  *

上面第二行代码的四项内容分别对应第一行中的四项。“test@gd.cn”是 Client 端的连接的用户名;“server”对应的是 VPS 服务器的名字,该名字必须和/etc/ppp/options.pptpd 文件中指明的一样,或者设置成“”号来表示自动识别服务器;“secret”对应的是登录密码;“IP addresses”对应的是可以拨入的客户端 IP 地址,如果不需要做特别限制,可以将其设置为“”号。

4、vim /etc/sysctl.conf ##开启 IP 转发

#   Kernel sysctl configuration file for Red Hat Linux
#   For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
#   sysctl.conf(5) for more details.
#   Controls IP packet forwarding
net.ipv4.ip_forward = 1 ## 将这个值改为 1 其他的不动
#   Controls source route verification net.ipv4.conf.default.rp_filter = 0
#   Do not accept source routing net.ipv4.conf.default.accept_source_route = 0
#   Controls the System Request debugging functionality of the kernel kernel.sysrq = 0

5、sysctl -p (强制刷新)

net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296

五、iptables

需要开启 1723 端口

iptables -A INPUT -p tcp -m tcp --dport 1723 -j ACCEPT  (开启 1723 端口)
/etc/init.d/iptables save   ##保存防火墙配置
/etc/init.d/iptables resart ##重启防火墙
chkconfig iptables --level 345 on (开机自动启动)
chkconfig pptpd --level 345 on
/etc/init.d/pptpd start (启动 pptpd)
Starting pptpd:      [确定]

六、测试

Win10 系统设置 *PN 的方法:

1、要在 Win10 上设置 PN,请单击左下角的“开始”按钮,然后选择“设置”选项。 然后单击“网络和 Internet”,然后单击“PN”。下一步是单击“添加 *PN 连接”,之后是时候添加所有必需的信息。

2、首先单击“PN 提供商”下拉列表,然后选择唯一可用的选项 - Windows(内置)。 在“连接名称”字段中,键入您希望连接到 PN 时可以识别的选项名称。

3、现在是时候添加一个“服务器名称或地址”,选择“*PN 类型”下的“自动”选项,然后选择“登录信息类型”选项之一。在大多数情况下,这将是默认值 - “用户名和密码”。

4、下一步是将您的输入信息添加到“用户名”和“密码”字段,然后单击“保存”按钮完成该过程。

注:如果连接* PN 后本机不能连接上网,点击如下设置:

Centos6配置PPTP连接VPS服务器

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI