0xAA55 发表于 2017-1-16 11:23:29

【Linux】CentOS 6如何配置VPN客户端

1、安装ppp和pptp

# yum -y install ppp pptp

2、配置你的VPN用户名和密码

# vi /etc/ppp/chap-secrets

添加一行内容,格式如下:

用户名 PPTP 密码 *

比如我的用户名是foo,密码是2b2b2b2b2b,那么我的chap-secrets文件里面应该就有这样的一行内容:

foo PPTP 2b2b2b2b2b *

3、添加VPN连接配置。

#vi /etc/ppp/peers/配置名

这个“配置名”可以改成任意你喜欢的名字,最好全英文,不能有空格。比如bar。
然后在这个里面,输入以下的内容:pty "pptp 你的VPN服务器的地址 --nolaunchpppd"
name 你的用户名
remotename PPTP
require-mppe-128
file /etc/ppp/options.pptp
ipparam 配置名其中的“require-mppe-128”意为你需要mppe-128的加密。

4、播VPN连接。

运行以下命令:

# modprobe nf_conntrack_pptp
# pppd call 连接名

然后通过监视/var/log/messages来观察它的连接情况。Jan 16 01:10:23 ip-xxx-xxx-xxx-xxx pppd: pppd 2.4.5 started by ec2-user, uid 0
Jan 16 01:10:23 ip-xxx-xxx-xxx-xxx pppd: Using interface ppp0
Jan 16 01:10:23 ip-xxx-xxx-xxx-xxx pppd: Connect: ppp0 <--> /dev/pts/0
Jan 16 01:10:23 ip-xxx-xxx-xxx-xxx pptp: anon log: The synchronous pptp option is NOT activated
Jan 16 01:10:24 ip-xxx-xxx-xxx-xxx pptp: anon log: Sent control packet type is 1 'Start-Control-Connection-Request'
Jan 16 01:10:24 ip-xxx-xxx-xxx-xxx pptp: anon log: Received Start Control Connection Reply
Jan 16 01:10:24 ip-xxx-xxx-xxx-xxx pptp: anon log: Client connection established.
Jan 16 01:10:25 ip-xxx-xxx-xxx-xxx pptp: anon log: Sent control packet type is 7 'Outgoing-Call-Request'
Jan 16 01:10:25 ip-xxx-xxx-xxx-xxx pptp: anon log: Received Outgoing Call Reply.
Jan 16 01:10:25 ip-xxx-xxx-xxx-xxx pptp: anon log: Outgoing call established (call ID 0, peer's call ID 43295).
Jan 16 01:10:25 ip-xxx-xxx-xxx-xxx pptp: anon log: PPTP_SET_LINK_INFO received from peer_callid 0
Jan 16 01:10:25 ip-xxx-xxx-xxx-xxx pptp: anon log:   send_accm is 00000000, recv_accm is FFFFFFFF
Jan 16 01:10:25 ip-xxx-xxx-xxx-xxx pptp: anon warn: Non-zero Async Control Character Maps are not supported!
Jan 16 01:10:26 ip-xxx-xxx-xxx-xxx pppd: CHAP authentication succeeded
Jan 16 01:10:26 ip-xxx-xxx-xxx-xxx pppd: MPPE 128-bit stateless compression enabled
Jan 16 01:10:27 ip-xxx-xxx-xxx-xxx pppd: localIP address xxx.xxx.xxx.xxx
Jan 16 01:10:27 ip-xxx-xxx-xxx-xxx pppd: remote IP address 192.168.xxx.1这其中你能看到你被分配了一个IP地址了,就证明你成功连上了VPN。

5、设置静态路由表,让你的包裹经过你的VPN发出。

这个请参考route命令。

# ip route add 0.0.0.0/0 via 192.168.1.254 dev ppp0

这句会让所有的包裹经过VPN发出。

6、断开连接的方法:

# killall pppd
页: [1]
查看完整版本: 【Linux】CentOS 6如何配置VPN客户端