我在亚马逊CentOS上运行了EC2 6.4,使用了来自EPEL存储库的xl2tpd-1.3.1和StrongSwan 5.0.4。
我设置了一个简单的IPSec连接:
conn l2tp
type=transport
keyexchange=ikev1
rekey=no
authby=psk
leftsubnet=0.0.0.0/0
rightsubnet=0.0.0.0/0
compress=yes
auto=add下面是xl2tpd.conf:
[global]
ipsec saref = yes
[lns default]
ip range = 192.168.0.2-192.168.0.250
local ip = 192.168.0.1
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes以下是options.xl2tpd:
ms-dns 8.8.4.4
auth
lock
debug
proxyarp只有一个客户端-Android4.2
Android成功连接:
Oct 27 19:45:02 ip-172-31-17-30 xl2tpd[2706]: Connection established to x.x.x.x, 59578. Local: 18934, Remote: 29291 (ref=0/0). LNS session is 'default'
Oct 27 19:45:02 ip-172-31-17-30 xl2tpd[2706]: Call established with x.x.x.x, Local: 36452, Remote: 29845, Serial: -1369754322
Oct 27 19:45:02 ip-172-31-17-30 pppd[2709]: pppd 2.4.5 started by howard, uid 0
Oct 27 19:45:02 ip-172-31-17-30 pppd[2709]: Using interface ppp0
Oct 27 19:45:02 ip-172-31-17-30 pppd[2709]: Connect: ppp0 <--> /dev/pts/0
Oct 27 19:45:02 ip-172-31-17-30 pppd[2709]: peer from calling number x.x.x.x authorized
Oct 27 19:45:02 ip-172-31-17-30 pppd[2709]: Deflate (15) compression enabled
Oct 27 19:45:03 ip-172-31-17-30 pppd[2709]: Cannot determine ethernet address for proxy ARP
Oct 27 19:45:03 ip-172-31-17-30 pppd[2709]: local IP address 192.168.0.1
Oct 27 19:45:03 ip-172-31-17-30 pppd[2709]: remote IP address 192.168.0.2
Oct 27 19:45:03 ip-172-31-17-30 charon: 06[KNL] 192.168.0.1 appeared on ppp0
Oct 27 19:45:03 ip-172-31-17-30 charon: 06[KNL] 192.168.0.1 disappeared from ppp0
Oct 27 19:45:03 ip-172-31-17-30 charon: 06[KNL] 192.168.0.1 appeared on ppp0
Oct 27 19:45:03 ip-172-31-17-30 charon: 06[KNL] interface ppp0 activated同时,Internet在Android客户端上运行良好,VPN连接稳定快速。
但是,在建立连接后的2-5分钟内,总是会发生这样的情况:
Oct 27 19:47:07 ip-172-31-17-30 xl2tpd[2706]: Maximum retries exceeded for tunnel 18934. Closing.
Oct 27 19:47:07 ip-172-31-17-30 xl2tpd[2706]: Connection 29291 closed to 95.91.227.224, port 59578 (Timeout)
Oct 27 19:47:07 ip-172-31-17-30 charon: 06[KNL] interface ppp0 deactivated
Oct 27 19:47:07 ip-172-31-17-30 charon: 06[KNL] interface ppp0 deleted然后VPN连接中断。
那么什么可能出了问题呢?
相同的L2TP服务在iOS 7、MacOS 10.8和Windows7上运行得非常完美,在这些OSes上没有断开连接的问题。
谢谢!
发布于 2013-11-16 13:11:35
经过近一个月的调试工作,我仍然不能给出一个明确的问题的答案,但有一个解决办法。
在最初的问题中,Android客户端似乎总是请求隧道两次--“对等请求隧道xxx两次”,但其他客户端(MacOS、Macbook、Windows 7、iOS)不会出现这种情况。
在源代码中,如果重传计数器达到一定的阈值,xl2tpd就会杀死一个隧道,它会记录一条消息,上面写着“隧道xxx超过了最大重试次数”,然后在PPP连接上挂断。
但问题是:无论出于什么原因,隧道都是被积极使用的隧道,所以挂起它就意味着终止安卓的L2TP连接。
因此,我最终将xl2tpd版本1.3.1分叉到分支1.3.1中的https://github.com/HouzuoGuo/xl2tpd中。使用我的修复,xl2tpd不再在“超过最大重试”时杀死隧道,它只是记录一条消息并继续前进。
现在所有的客户端都很满意,Android不再断开连接,相同的配置在MacOS/iOS/Windows 7上仍然运行得很好。
顺便说一下,xl2tpd 1.3.2已经发布了,但是根据我的测试,它根本不适用于安卓:
select()超时的调度程序产生的超时时间太短(子秒),导致大量网络超时,而Android L2TP连接无法及时建立。select()超时时间被手动更改(5秒或10秒),“对等请求隧道xxx两次”问题不仅存在,而且还会变得更糟-- Android根本无法建立连接。https://serverfault.com/questions/550377
复制相似问题