Install pptp-linux 1.7.2 on debian lenny

Sunday, November 15th, 2009 @ 11:35 pm

同事给了我一个新的VPN帐号,windows能正常连接公司的VPN Server,可在linux中报下面错误:

CHAP authentication failed: Authentication failed.
CHAP authentication failed

查了半天,pptp-linux官方文档中的一句话点醒梦中人:

if the passwords contain any special characters, quote them.

因为新帐号的密码含有特殊字符,只要将密码用双引号括起来就OK了。pptp-linux是个很好用的工具,感觉比Cisco官方的client(公司用的是Cisco设备)还要稳定。下面说说如何安装和配置pptp-linux:

安装

sudo aptitude install pptp-linux

PPTP options

$ sudo vi /etc/ppp/options.pptp

options.pptp记录多个vpn连接的公用配置项,下面是我的配置:

# Lock the port
lock

# Authentication
# We don't need the tunnel server to authenticate itself
noauth

# We won't do PAP, EAP, CHAP, or MSCHAP, but we will accept MSCHAP-V2
# (you may need to remove these refusals if the server is not using MPPE)
refuse-pap
refuse-eap
#refuse-chap
refuse-mschap

# Compression
# Turn off compression protocols we know won't be used
nobsdcomp
nodeflate

# Encryption
# (There have been multiple versions of PPP with encryption support,
# choose with of the following sections you will use.  Note that MPPE
# requires the use of MSCHAP-V2 during authentication)

# http://ppp.samba.org/ the PPP project version of PPP by Paul Mackarras
# ppp-2.4.2 or later with MPPE only, kernel module ppp_mppe.o
# {{{
# Require MPPE 128-bit encryption
#require-mppe-128
# }}}

# http://polbox.com/h/hs001/ fork from PPP project by Jan Dubiec
# ppp-2.4.2 or later with MPPE and MPPC, kernel module ppp_mppe_mppc.o
# {{{
# Require MPPE 128-bit encryption
#mppe required,stateless
# }}}

因为我们使用CHAP进行身份认证,所以注释掉refuse-chap,同时还注释掉require-mppe-128,不用MPPE的支持。

配置一个VPN连接
如果用CHAP进行认证,那么:

$ sudo vi /etc/ppp/chap-secrets

添加你的vpn帐户信息,没有的话问系统管理员要:

# Secrets for authentication using CHAP
# client	server	secret			IP addresses
username PPTP "password" *

/etc/ppp/peers/目录下,为指定vpn连接建立一个配置文件:

$ sudo vi /etc/ppp/peers/gaixie

内容如下:

pty "pptp vpn.server.ip --nolaunchpppd"
name username
remotename PPTP
file /etc/ppp/options.pptp
ipparam gaixie

vpn.server.ip替换为你要连接的VPN Server的IP地址。

配置路由
/etc/ppp/ip-up.d新增一个shell文件:

$ sudo vi /etc/ppp/ip-up.d/gaixie

内容如下:

#!/bin/bash
NET="10.0.0.0/8" # set me
IFACE="ppp0" # set me
#IFACE=$1
route add -net ${NET} dev ${IFACE}

注意:如果使用无线网卡进行连接,无线网卡拨号后会先占用ppp0,应该将上面的ppp0改为ppp1。
为此文件加上执行权限:

$ sudo chmod +x /etc/ppp/ip-up.d/gaixie 

10.0.0.0/8 为CIDR表示法,vpn连接时,会通过/etc/ppp/ip-up执行上面的脚本,从而加入正确的路由信息。

测试连接
启动vpn连接

$ sudo pon gaixie

debug模式启动

$ sudo pon gaixie debug dump logfd 2 nodetach 

断开vpn连接

$ sudo poff gaixie  

Tags: ,
Posted in Technology | 1 Comment »

One Response to “Install pptp-linux 1.7.2 on debian lenny”

  1. xzy says:

    按此方法在ubuntu下设置了一下,可以使用,没有问题。

Leave a Reply