当前位置: > Linux服务器 > VPN >

CentOS 6.0(64bit) 安装 PPTP VPN

时间:2014-11-30 15:10来源:linux.it.net.cn 作者:IT

最近公司大部分人需要vpn看一些国外的东西,但是付费的vpn有限制,所以公司买了vps决定自己搭建vpn,一下是我搭建PPTP VPN的全部过程。

 

一、PPTP 协议介绍

PPTP: Point to Point Tunneling Protocol

  点对点隧道协议(PPTP)是一种支持多协议虚拟专用网络的网络技术。通过该协议,远程用户能够通过 Microsoft Windows NT 工作站、Windows 95 和 Windows 98 操作系统以及其它装有点对点协议的系统安全访问公司网络,并能拨号连入本地 ISP,通过 Internet 安全链接到公司网络。

   PPTP 可以用于在 IP 网络上建立 PPP 会话隧道。在这种配置下,PPTP 隧道和 PPP 会话运行在两个相同的机器上,呼叫方充当 PNS。PPTP 使用客户机-服务器结构来分离当前网络访问服务器具备的一些功能并支持虚拟专用网络。PPTP 作为一个呼叫控制和管理协议,它允许服务器控制来自 PSTN 或 ISDN 的拨入电路交换呼叫访问并初始化外部电路交换连接。

  PPTP 只能通过 PAC 和 PNS 来实施,其它系统没有必要知道 PPTP。拨号网络可与 PAC 相连接而无需知道 PPTP。标准的 PPP 客户机软件可继续在隧道 PPP 链接上操作。

  PPTP 使用 GRE 的扩展版本来传输用户 PPP 包。这些增强允许为在 PAC 和 PNS 之间传输用户数据的隧道提供低层拥塞控制和流控制。这种机制允许高效使用隧道可用带宽并且避免了不必要的重发和缓冲区溢出。PPTP 没有规定特定的算法用于低层控制,但它确实定义了一些通信参数来支持这样的算法工作。

 

 

二、环境

1、Linode VPS:很有名的一家Linux专业VPS供应商,国内访问速度还不错。http://www.linode.com
2、CentOS:著名的Linux发行版。http://www.centos.org

3、pptp:与OpenVPN齐名的VPN服务器。

 

三、服务端安装步骤

1、因为pptp需要MPPE的支持,所以首先检测系统是否符已经编译了MPPE。如果没有,那请您别往下看了。

下面介绍几种种检测方法,只要符合其中的一条就可以

 

[root@li402-211 PPTP]# zgrep MPPE /proc/config.gz

 

 

 

 

 

点击查看原图

 

cat /dev/net/tun

点击查看原图

下面一种在我的vps上没有得到预期目标,但是不受影响

 

 

modprobe ppp-compress-18 && echo ok
点击查看原图

 

 

strings '/usr/sbin/pppd' |grep -i mppe | wc --lines

如果以上命令输出为“0”则表示不支持;输出为“30”或更大的数字就表示支持。

点击查看原图

 

 

2、由于pptp需要iptables支持,所以需要安装iptables。如果您的服务器上已经安装了iptables,那么可以只安装pptp

 

yum install -y ppp iptables 
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.rhel5.x86_64.rpm 
rpm -ivh pptpd-1.3.4-2.rhel5.x86_64.rpm

 

3、配置文件的编写

 

vi /etc/pptpd.conf

 

###############################################################################

# $Id: pptpd.conf,v 1.10 2006/09/04 23:30:57 quozl Exp $

#

# Sample Poptop configuration file /etc/pptpd.conf

#

# Changes are effective when pptpd is restarted.

###############################################################################

 

# TAG: ppp

# Path to the pppd program, default '/usr/sbin/pppd' on Linux

#

#ppp /usr/sbin/pppd

 

# TAG: option

# Specifies the location of the PPP options file.

# By default PPP looks in '/etc/ppp/options'

#

option /etc/ppp/options.pptpd

 

# TAG: debug

# Turns on (more) debugging to syslog

#

#debug

 

# TAG: stimeout

# Specifies timeout (in seconds) on starting ctrl connection

#

# stimeout 10

 

# TAG: noipparam

#       Suppress the passing of the client's IP address to PPP, which is

#       done by default otherwise.

#

#noipparam

 

# TAG: logwtmp

# Use wtmp(5) to record client connections and disconnections.

#

#logwtmp

 

# TAG: bcrelay <if>

# Turns on broadcast relay to clients from interface <if>

#

#bcrelay eth1

 

# TAG: delegate

# Delegates the allocation of client IP addresses to pppd.

#

#       Without this option, which is the default, pptpd manages the list of

#       IP addresses for clients and passes the next free address to pppd.

#       With this option, pptpd does not pass an address, and so pppd may use

#       radius or chap-secrets to allocate an address.

#

#delegate

 

# TAG: connections

#       Limits the number of client connections that may be accepted.

#

#       If pptpd is allocating IP addresses (e.g. delegate is not

#       used) then the number of connections is also limited by the

#       remoteip option.  The default is 100.

#connections 100

 

# TAG: localip

# TAG: remoteip

# Specifies the local and remote IP address ranges.

#

# These options are ignored if delegate option is set.

#

#       Any addresses work as long as the local machine takes care of the

#       routing.  But if you want to use MS-Windows networking, you should

#       use IP addresses out of the LAN address space and use the proxyarp

#       option in the pppd options file, or run bcrelay.

#

# You can specify single IP addresses seperated by commas or you can

# specify ranges, or both. For example:

#

# 192.168.0.234,192.168.0.245-249,192.168.0.254

#

# IMPORTANT RESTRICTIONS:

#

# 1. No spaces are permitted between commas or within addresses.

#

# 2. If you give more IP addresses than the value of connections,

#    it will start at the beginning of the list and go until it

#    gets connections IPs.  Others will be ignored.

#

# 3. No shortcuts in ranges! ie. 234-8 does not mean 234 to 238,

#    you must type 234-238 if you mean this.

#

# 4. If you give a single localIP, that's ok - all local IPs will

#    be set to the given one. You MUST still give at least one remote

#    IP for each simultaneous client.

#

# (Recommended)

localip 192.168.10.1

remoteip 192.168.10.10-254

# or

#localip 192.168.0.234-238,192.168.0.245

#remoteip 192.168.1.234-238,192.168.1.245

 

localip 是给vpn服务器分配的的ip,不一定是服务器的外网ip
remoteip 是服务器分给客户端的ip

 

 

 

vi /etc/ppp/options.pptpd

 

###############################################################################

# $Id: options.pptpd,v 1.11 2005/12/29 01:21:09 quozl Exp $

#

# Sample Poptop PPP options file /etc/ppp/options.pptpd

# Options used by PPP when a connection arrives from a client.

# This file is pointed to by /etc/pptpd.conf option keyword.

# Changes are effective on the next connection.  See "man pppd".

#

# You are expected to change this file to suit your system.  As

# packaged, it requires PPP 2.4.2 and the kernel MPPE module.

###############################################################################

 

 

# Authentication

 

# Name of the local system for authentication purposes 

# (must match the second field in /etc/ppp/chap-secrets entries)

name pptpd

 

# Strip the domain prefix from the username before authentication.

# (applies if you use pppd with chapms-strip-domain patch)

#chapms-strip-domain

 

 

# Encryption

# (There have been multiple versions of PPP with encryption support,

# choose with of the following sections you will use.)

 

 

# BSD licensed ppp-2.4.2 upstream with MPPE only, kernel module ppp_mppe.o

# {{{

refuse-pap

refuse-chap

refuse-mschap

# Require the peer to authenticate itself using MS-CHAPv2 [Microsoft

# Challenge Handshake Authentication Protocol, Version 2] authentication.

require-mschap-v2

# Require MPPE 128-bit encryption

# (note that MPPE requires the use of MSCHAP-V2 during authentication)

require-mppe-128

# }}}

 

 

# OpenSSL licensed ppp-2.4.1 fork with MPPE only, kernel module mppe.o

# {{{

#-chap

#-chapms

# Require the peer to authenticate itself using MS-CHAPv2 [Microsoft

# Challenge Handshake Authentication Protocol, Version 2] authentication.

#+chapms-v2

# Require MPPE encryption

# (note that MPPE requires the use of MSCHAP-V2 during authentication)

#mppe-40 # enable either 40-bit or 128-bit, not both

#mppe-128

#mppe-stateless

# }}}

 

 

# Network and Routing

 

# If pppd is acting as a server for Microsoft Windows clients, this

# option allows pppd to supply one or two DNS (Domain Name Server)

# addresses to the clients.  The first instance of this option

# specifies the primary DNS address; the second instance (if given)

# specifies the secondary DNS address.

#ms-dns 10.0.0.1

#ms-dns 10.0.0.2

 

ms-dns 106.182.34.20

ms-dns 106.182.35.20

ms-dns 106.182.36.20

 

# If pppd is acting as a server for Microsoft Windows or "Samba"

# clients, this option allows pppd to supply one or two WINS (Windows

# Internet Name Services) server addresses to the clients.  The first

# instance of this option specifies the primary WINS address; the

# second instance (if given) specifies the secondary WINS address.

#ms-wins 10.0.0.3

#ms-wins 10.0.0.4

 

# Add an entry to this system's ARP [Address Resolution Protocol]

# table with the IP address of the peer and the Ethernet address of this

# system.  This will have the effect of making the peer appear to other

# systems to be on the local ethernet.

# (you do not need this if your PPTP server is responsible for routing

# packets to the clients -- James Cameron)

proxyarp

 

# Normally pptpd passes the IP address to pppd, but if pptpd has been

# given the delegate option in pptpd.conf or the --delegate command line

# option, then pppd will use chap-secrets or radius to allocate the

# client IP address.  The default local IP address used at the server

# end is often the same as the address of the server.  To override this,

# specify the local IP address here.

# (you must not use this unless you have used the delegate option)

#10.8.0.100

 

 

# 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

 

 

# Miscellaneous

 

# Create a UUCP-style lock file for the pseudo-tty to ensure exclusive

# access.

lock

 

# Disable BSD-Compress compression

nobsdcomp 

 

# Disable Van Jacobson compression 

# (needed on some networks with Windows 9x/ME/XP clients, see posting to

# poptop-server on 14th April 2005 by Pawel Pokrywka and followups,

# http://marc.theaimsgroup.com/?t=111343175400006&r=1&w=2 )

novj

novjccomp

 

# turn off logging to stderr, since this may be redirected to pptpd, 

# which may trigger a loopback

nologfd

idle 2592000

# put plugins here 

# (putting them higher up may cause them to sent messages to the pty)

 

ms-dns 是服务器上的dns
 
vi /etc/ppp/chap-secrets
 
# Secrets for authentication using CHAP
# client server secret IP addresses
wangshangyou pptpd wangshangyou *
这里的wangshangyou 和 wangshangyou 分别为登陆PPTP VPN 的用户名和密码,server应该对应 options.pptpd 配置里面name对应的值,ip如果位*则表示自动分配,也可以手动分配
4、启动PPTP服务
service pptpd start

 

5、打开防火墙转发

 

sysctl -w net.ipv4.ip_forward=1

6、开启防火墙服务

 

/sbin/service iptables start

 

 

iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth0 -j SNAT --to-source 106.182.53.211 
-s 后面的ip为给客户端分配的ip --to--source 后面的ip为 vpn服务器端的外网ip
/etc/init.d/iptables save 
/etc/init.d/iptables restart

至此PPTP服务已经安装完毕,下面来让我们配置一下客户端把

 

 

四、客户端安装步骤

 

直接上图了

点击查看原图

点击查看原图

点击查看原图

点击查看原图

点击查看原图

点击查看原图

点击查看原图

点击查看原图

ok了,如果期间出现链接不上试着下图配置

点击属性 网络 VPN类型改为 PPTP VPN

点击查看原图

标签: linux CentOS PPTP VPN 6.0(64bit) 安装

 

(责任编辑:IT)
------分隔线----------------------------