星哥的博客

  • 首页
  • 系统
  • 虚拟机
  • 网站开发
  • 硬件外设
  • VPS/云主机
  • 心情随笔
  1. 首页
  2. 系统
  3. Linux
  4. 正文

CentOS下安装PPTP VPN小记

2012年12月25日 2463点热度 0人点赞 0条评论

pptpd VPN需要内核支持mppe,如果不支持,请联系你的服务商,或者宣告失败吧。

首先,在安装之前,需要检测服务器是否支持ppp,运行

#zgrep MPPE /proc/config.gz
CONFIG_PPP_MPPE=y

显示y则支持

还要检测服务器是否开启了tun/tap,运行

#cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state 返回这样的信息说明服务器开启了tun/tap

下面开始配置。
先安装ppp和iptables。

yum install -y ppp iptables


如果出现以下情况

[root@poorren~]# yum install -y ppp iptables
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.kernel.org
* updates: mirrors.kernel.org
* addons: mirrors.kernel.org
* extras: mirrors.kernel.org
http://download.lxlabs.com/download/update/centos-5/i386/repodata/repomd.xml: [Errno 4] IOError: <urlopen error (-3, ‘Temporary failure in name resolution’)>
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: lxlabsupdate. Please verify its path and try again

请先执行

yum clean all

再执行

yum install -y ppp iptables

然后下载pptpd。

5.X CentOS:

32位操作系统.

wget https://acelnmp.googlecode.com/files/pptpd-1.3.4-2.rhel5.i386.rpm
rpm -ivh pptpd-1.3.4-2.rhel5.i386.rpm

64位操作系统.

wget https://acelnmp.googlecode.com/files/pptpd-1.3.4-2.rhel5.x86_64.rpm
rpm -ivh pptpd-1.3.4-2.rhel5.x86_64.rpm

6.X CentOS:

32位操作系统.

wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.i686.rpm
rpm -ivh pptpd-1.3.4-2.el6.i686.rpm

64位操作系统.

wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.x86_64.rpm
rpm -ivh pptpd-1.3.4-2.el6.x86_64.rpm

接下来编辑/etc/pptpd.conf文件,去掉下面两行的注释或者直接添加这两行

vi /etc/pptpd.conf
localip 192.168.0.1
remoteip 192.168.0.234-238,192.168.0.245

添加VPN用户和密码,按照下面格式.密码后的*号保留.

vi /etc/ppp/chap-secrets
username pptpd password *

设置DNS为Google的DNS.

vi /etc/ppp/options.pptpd

为了测试,请打开debug和dump

# Logging

# Enable connection debugging facilities.
# (see your syslog configuration for where pppd sends to)
debug

# Print out all the option values which have been set.
# (often requested by mailing list to verify options)
dump

默认的信息会写在/var/log/messages

找到ms-dns改成.

ms-dns 8.8.8.8
ms-dns 8.8.4.4

以下是配置说明:

#相当于身份验证时的域,一定要和/etc/ppp/chap-secrets中的内容对应,下面会讲到。
name pptpd
#传输加密。ppp-2.4.2以上的版本只支持MPPE加密,内核模块为 ppp_mppe.o
#拒绝pap身份验证
refuse-pap
#拒绝chap身份验证
refuse-chap
#拒绝mschap身份验证
refuse-mschap
#采用mschap-v2(Microsoft Challenge Handshake Authentication Protocol, Version 2)身份验证方式
require-mschap-v2
#注意在采用mschap-v2身份验证方式时要使用MPPE进行加密
require-mppe-128
#给客户端分配DNS地址和WINS服务器地址
ms-dns 202.99.96.68
#ms-wins 10.0.0.4
#启动ARP代理,如果分配给客户端的IP地址与内网网卡在一个子网就需要启用ARP代理。
Proxyarp

编辑/etc/sysctl.conf文件,找到”net.ipv4.ip_forward=1″这一行,去掉前面的注释。没有就添加上.

net.ipv4.ip_forward=1

运行下面的命令让配置生效。

sysctl -p

重启pptpd服务

/etc/init.d/pptpd restart

最后开启iptables转发

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

保存iptables

/etc/init.d/iptables save

然后重启iptables

/etc/init.d/iptables restart

再重启pptp

/etc/init.d/pptpd restart

最后设置iptables和pptpd开机自动启动

chkconfig pptpd on
chkconfig iptables on

到这里大功告成了。在本地直接建立vpn连接,登陆即可。如果登陆后仍然打不开网页,先断开连接,将vpn连接的tcp/ip属性-高级中的在远程网络上使用默认网关取消。

标签: 暂无
最后更新:2013年2月28日

wangxingcs

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

This site uses Akismet to reduce spam. Learn how your comment data is processed.

wangxingcs

这个人很懒,什么都没留下

我的博客

仅记录一些有用的教程,自己的经历,已屏蔽各大搜索引擎收录。

新浪微博 @wangxingcs

Twitter @wangxingcs(常在)

最新 热点 随机
最新 热点 随机
Proxmox VE(PVE)6.X 添加硬盘 PVE解决VM is locked问题 Proxmox VE配置更新源 黑群晖显示真实CPU信息(支持7.0.1) Proxmox VE直通硬盘(全盘映射方式) PVE去除“没有有效订阅”提示
dede文章列表页和文章内页调用tag的方法 在首页显示论坛所有帖子 自己动手更换极光2的WIFI天线 解决WIFI信号断流或减弱的问题 解决linux下/etc/rc.local开机器不执行的原因 Linux流量监控工具 - iftop Proxmox VE配置更新源
标签聚合
CMS 虚拟机 DSM FineCMS PVE MTP 驱动 群晖

COPYRIGHT © 2015-2023 wangxingcs.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

陕ICP备13007295号