pptp

1、检查服务器是否有必要的支持。如果检查结果没有这些支持的话,是不能安装pptp的。执行指令:
#modprobe ppp-compress-18 && echo ok(用模块方式支持MPPE加密模式浏览,如果内核支持检测不到。)
这条执行执行后,显示“ok”则表明通过。

2、安装ppp和iptables。默认情况下,完整的CentOS是带有这两个组件的,但是精简版的系统可能没有。我们输入下面的命令来确认,如果没有则进行安装,有的话系统不会做任何动作:
#yum install -y iptables

3、安装pptp。这个软件在yum源里是没有的,我们需要手动下载。
加入yum源:
#rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm
#yum install  -y pptpd

4、配置pptp。首先我们要编辑/etc/pptpd.conf文件:
#vim /etc/pptpd.conf

localip 192.168.11.1
remoteip 192.168.11.2-102  (最大限制100个连接)
将前面的“#”注释符去掉,更改为你期望的IP段值。localip表示服务器的IP,remoteip表示分配给客户端的IP地址,可以设置为区间。这里我们使用pptp默认的配置:

再编辑/etc/ppp/options.pptpd文件,为VPN添加Google DNS:
#vim /etc/ppp/options.pptpd
在末尾添加下面两行:
ms-dns 8.8.8.8
ms-dns 8.8.4.4

注意:最好打开这个文件里的debug选项(去掉debug前面的“#”),以方便我们在出错的查看日志排错。错误日志在/var/log/messages里,用命令:cat /var/log/messages | grep pptpd 查看有关PPTP的错误信息。

5、设置pptp VPN账号密码。我们需要编辑/etc/ppp/chap-secrets这个文件:
#vim /etc/ppp/chap-secrets
在这个文件里面,按照“用户名 pptpd 密码 *”的形式编写,一行一个账号和密码。比如添加用户名为test,密码为1234的用户,则编辑如下内容:
test pptpd 1234 *

6、修改内核设置,使其支持转发。编辑/etc/sysctl.conf文件:
#vim /etc/sysctl.conf
将“net.ipv4.ip_forward”改为1,变成下面的形式:
net.ipv4.ip_forward=1
保存退出,并执行下面的命令来生效它:
#sysctl -p

7、添加iptables转发规则。经过前面的6个步骤,我们的VPN已经可以拨号了,但是还不能访问任何网页。最后一步就是添加iptables转发规则了,输入下面的指令:
两种修改方法:命令行或修改/etc/sysconf/iptables 文件
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.11.0/24 -j MASQUERADE

iptables -L -t nat 可以看到:
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
MASQUERADE  all  --  192.168.11.0/24      anywhere
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

在/etc/sysconf/iptables 文件 允许ping
-A RH-Firewall-1-INPUT -s 192.168.11.0/255.255.255.0 -p icmp -m icmp --icmp-type 8 -j ACCEPT
service iptables save  保存
service iptables restart 重启

8.
设置开机自动运行服务。我们最后一步是将pptp和iptables设置为开机自动运行,这样就不需要每次重启服务器后手动启动服务了。当然你不需要自动启动服务的话可以忽略这一步。输入指令:
#chkconfig pptpd on
#chkconfig iptables on

 

限制pptp vpn用户单个连接的简单方法

在/etc/ppp文件夹下面建立一个名为auth-up的文件。在里面写入如下内容即可:

#!/bin/sh
# get the username/ppp line number from the parameters
REALDEVICE=$1
USER=$2
# create the directory to keep pid files per user
mkdir -p /var/run/pptpd-users
# if there is a session already for this user, terminate the old one
if [ -f /var/run/pptpd-users/$USER ]; then
kill -HUP `cat /var/run/pptpd-users/$USER`
fi
# copy the pid file of current user to /var/run/pptpd-users
cp "/var/run/$REALDEVICE.pid" /var/run/pptpd-users/$USER

来源:http://vastars.info/linux/pptp-vpn.html

 

VPN 架设中一些问题的解决方法(pptpd)

1. windows 10 下服务器推送DNS无效

控制面板 > 网络与共享 > VPN所属适配器 > 属性 > IPv4 > 高级 > 取消自动跃点并设置值为 15

IPv6 同上

Control Panel > Network and Sharing Center > Change adapter settings > Right click your Ethernet or Wifi adapter > Properties > double click IPv4 > Advanced > Uncheck Automatic Metric > Enter 15 for interface metric > OK > OK.

On that same Properties page, double click IPv6 > Advanced > Uncheck Automatic Metric > Enter 15 for interface metric > OK > OK.

2.VPN可以连接成功,但不能正常上网,messages中记录如下:

       Cannot determine ethernet address for proxy ARP

   该问题主要出在没有相关的转发规则。需要进行如下配置:

   a.打开配置文件/etc/sysctl.conf,修改配置项net.ipv4.ip_forward为1:    

# Controls IP packet forwarding

net.ipv4.ip_forward = 1

       该配置项用于允许ip转发。

   b.还需在iptables中加入NAT转换:

       iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.255.0 -j SNAT --to-source 192.168.0.88

       其中192.168.0.0/255.255.255.0为VPN的内部网络,192.168.0.88当然就是服务器的地址了。

3. 如sysctl -p

error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key

error: "net.bridge.bridge-nf-call-arptables" is an unknown key

调用并重试pptpd

modprobe bridge
lsmod|grep bridge

 

Windows7 619一些参考:

http://www.wanghailin.cn/linux-pptpd-619-internet/

GRE: read(fd=6,buffer=b77c8480,len=8196) from PTY failed:

Changing /etc/ppp/pptpd-options to the following options worked for me:

refuse-pap
refuse-chap
refuse-mschap
#require-chap
#require-mschap
#require-mschap-v2
#require-mppe-128
mppe-stateful

 

 

CentOS 7 参考:

http://www.wanghailin.cn/centos-7-vpn/

 

一些MTU参考:

Ethernet MinSize = 512bit = 64 Byte
Ethernet MaxSize = 1518 Byte
so Ethernet IP MTU = 1518 – 18 ( 6 SRCMAC+ 6 DSTMAC+ 2 TYPE+ 4 CRC) = 1500 B
so Ethernet IP TCP MSS = 1500 – 40 ( 20 IP_HEADER + 20 TCP_HEADER) = 1460 B
so Ethernet IP UDP MTU/MRU = 1500 – 28 ( 20 IP_HEADER + 8 UDP_HEADER ) = 1472 B
so PPPoE MTU/MRU = 1500 – 8 ( 6 PPPoE_SESSION + 2 PPP_HEADER ) = 1492 B
so TCP over PPPoE MSS = 1492 ( PPPoE MTU/MRU ) – 40 ( 20 IP_HEADER + 20 TCP_HEADER) = 1452
so PPTP MTU/MRU = 1500 – 56 ( 20 IP_HEADER + 20 TCP_HEADER + 12 GRE_HEADER + 4 PPP_HEADER ) = 1444 B
so TCP over PPTP MSS = 1444 ( PPTP MTU/MRU ) – 40 ( 20 IP_HEADER + 20 TCP_HEADER) = 1404
so L2TP MTU/MRU = 1500 – 40 ( 20 IP_HEADER +8 UDP_HEADER + 8 L2TP_HEADER + 4 PPP_HEADER ) = 1460 B
so TCP over L2TP MSS = 1460 ( L2TP MTU/MRU ) – 40 ( 20 IP_HEADER + 20 TCP_HEADER) = 1420 B

so
PPTP over PPPoE MTU/MRU = 1492 ( PPPoE MTU/MRU ) – 56 ( 20 IP_HEADER +
20 TCP_HEADER + 12 GRE_HEADER + 4 PPP_HEADER ) = 1436 B
so PPTP over PPTP MTU/MRU = 1444 ( PPTP MTU/MRU ) – 56 ( 20 IP_HEADER + 20 TCP_HEADER + 12 GRE_HEADER + 4 PPP_HEADER ) = 1388 B
so PPTP over L2TP MTU/MRU = 1460 ( L2TP MTU/MRU ) – 56 ( 20 IP_HEADER + 20 TCP_HEADER + 12 GRE_HEADER + 4 PPP_HEADER ) = 1404 B
so L2TP over PPPoE MTU/MRU = 1492 ( PPPoE MTU/MRU ) – 40 ( 20 IP_HEADER +8 UDP_HEADER + 8 L2TP_HEADER + 4 PPP_HEADER ) = 1452 B
so L2TP over PPTP MTU/MRU = 1444 ( PPTP MTU/MRU ) – 40 ( 20 IP_HEADER +8 UDP_HEADER + 8 L2TP_HEADER + 4 PPP_HEADER ) = 1404 B
so L2TP over L2TP MTU/MRU = 1460 ( L2TP MTU/MRU ) – 40 ( 20 IP_HEADER +8 UDP_HEADER + 8 L2TP_HEADER + 4 PPP_HEADER ) = 1420 B

此条目发表在linux分类目录,贴了, 标签。将固定链接加入收藏夹。