基于Linux 架设PPTP

最近折腾得东西太多太多,萌生写工作日志做梳理的想法,以便以后维护。

今天天气不错。

以下显示的java代码均为Linux指令,懒得一个个改

1、安装pptp、pptpd

rpm -Uvh http://pptpclient.sourceforge.net/yum/stable/rhel5/pptp-release-current.noarch.rpm
yum install pptpd

2、

主配置:vim /etc/pptpd.conf

localip 192.168.2.16
remoteip 192.168.2.50-90

 

localip=pptp server ip

remoteip:pptp地址池


添加PPTP用户账号密码:

vim /etc/ppp/chap-secrets

client        server  secret                  IP addresses
tang            pptpd   123456                *
tank            pptpd   123456                192.168.2.15

IP address=*会从pptp地址池获取ip
IP address=x.x.x.x 固定给此账号分配ip

3、配置pptp的dns

vim /etc/ppp/options.pptpd

在末尾增加

ms-dns 192.168.2.1
ms-dns 8.8.8.8

 
4、重启PPTP服务

service pptpd restart

 
此时会有警告信息如下

Warning: a pptpd restart does not terminate existing
connections, so new connections may be assigned the same IP
address and cause unexpected results.  Use restart-kill to
destroy existing connections during a restart.

 

提示这种方式重启不会中断已存在的pptp链接

以后重启服务器如需中断客户端链接可以使用

service pptpd restart-kill
service pptpd start

 
5、开启路由转发功能

vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

 
  6、配置NAT服务,使pptp分配的IP可以使用公网IP去访问互联网

iptables -t nat -A POSTROUTING -j MASQUERADE

 
7、客户端配置

yum install pptp

 
8、加载内核模块

modprobe ppp_mppe

 
9、创建一个链接配置文件 如:vim /etc/ppp/peers/pptpserver,加入如下内容

pty "pptp x.x.x.x --nolaunchpppd"

name tang

password 123456

remotename PPTP

require-mppe-128

x.x.x.x为pptp server的公网地址

10、连接VPN

pppd call pptpserver

 
11、增加缺省路由

route add default gw 192.168.2.16

猜你喜欢

转载自tank-tang.iteye.com/blog/1976364