L2TP/IPsec方式的vpn连接失败,请开发帮忙分析下
Tofloor
poster avatar
DebuggerX
deepin
2018-03-01 00:32
Author
这个问题长时间以来一直有人反馈,但可能是没能提供足够有效的信息所以一直没能解决。1年多以前我就没能连接成功,当时直接换ss方式了所以也就没管。最近由于工作需要必须用这个方式的vpn,所以花了点时间想看看能不能找出原因。

先上系统日志:

  1. -- Logs begin at Tue 2017-12-26 13:08:19 CST. --
  2. 2月 28 15:43:58 debuggerx-pc NetworkManager[908]: establishing connection '33d8fc19-a978-4ac2-a327-abfa07b5fbb4' failed
  3. 2月 28 15:43:58 debuggerx-pc charon[12302]: 10[IKE] received NO_PROPOSAL_CHOSEN error notify
  4. 2月 28 15:43:58 debuggerx-pc NetworkManager[908]: Stopping strongSwan IPsec...
  5. 2月 28 15:43:58 debuggerx-pc charon[12302]: 00[DMN] signal of type SIGINT received. Shutting down
  6. 2月 28 15:43:58 debuggerx-pc ipsec_starter[12301]: child 12302 (charon) has quit (exit code 0)
  7. 2月 28 15:43:58 debuggerx-pc ipsec_starter[12301]:
  8. 2月 28 15:43:58 debuggerx-pc nm-l2tp-service[12242]: g_dbus_method_invocation_take_error: assertion 'error != NULL' failed
  9. 2月 28 15:43:58 debuggerx-pc NetworkManager[908]:   [1519803838.9917] vpn-connection[0x5641a70576a0,33d8fc19-a978-4ac2-a327-abfa07b5fbb4,"flutter",0]: VPN plugin: state changed: stopped (6)
  10. 2月 28 15:43:58 debuggerx-pc NetworkManager[908]:   [1519803838.9935] vpn-connection[0x5641a70576a0,33d8fc19-a978-4ac2-a327-abfa07b5fbb4,"flutter",0]: VPN service disappeared
  11. 2月 28 15:43:58 debuggerx-pc NetworkManager[908]:   [1519803838.9965] vpn-connection[0x5641a70576a0,33d8fc19-a978-4ac2-a327-abfa07b5fbb4,"flutter",0]: VPN connection: failed to connect: 'Message recipient disconnected from message bus without replying'
  12. 2月 28 15:46:40 debuggerx-pc NetworkManager[908]:   [1519804000.5405] audit: op="connection-activate" uuid="33d8fc19-a978-4ac2-a327-abfa07b5fbb4" name="flutter" pid=2439 uid=1000 result="success"
  13. 2月 28 15:46:40 debuggerx-pc NetworkManager[908]:   [1519804000.5453] vpn-connection[0x5641a70574b0,33d8fc19-a978-4ac2-a327-abfa07b5fbb4,"flutter",0]: Started the VPN service, PID 14102
  14. 2月 28 15:46:40 debuggerx-pc NetworkManager[908]: Stopping strongSwan IPsec failed: starter is not running
  15. 2月 28 15:46:40 debuggerx-pc NetworkManager[908]:   [1519804000.5529] vpn-connection[0x5641a70574b0,33d8fc19-a978-4ac2-a327-abfa07b5fbb4,"flutter",0]: Saw the service appear; activating connection
  16. 2月 28 15:46:40 debuggerx-pc nm-l2tp-service[14102]: Check port 1701
  17. 2月 28 15:46:42 debuggerx-pc NetworkManager[908]: Starting strongSwan 5.5.3 IPsec [starter]...
  18. 2月 28 15:46:42 debuggerx-pc NetworkManager[908]: Loading config setup
  19. 2月 28 15:46:42 debuggerx-pc NetworkManager[908]: Loading conn '33d8fc19-a978-4ac2-a327-abfa07b5fbb4'
  20. 2月 28 15:46:42 debuggerx-pc ipsec_starter[14117]: Starting strongSwan 5.5.3 IPsec [starter]...
  21. 2月 28 15:46:42 debuggerx-pc ipsec_starter[14117]: Loading config setup
  22. 2月 28 15:46:42 debuggerx-pc ipsec_starter[14117]: Loading conn '33d8fc19-a978-4ac2-a327-abfa07b5fbb4'
  23. 2月 28 15:46:42 debuggerx-pc NetworkManager[908]: found netkey IPsec stack
  24. 2月 28 15:46:42 debuggerx-pc ipsec_starter[14117]: found netkey IPsec stack
  25. 2月 28 15:46:42 debuggerx-pc ipsec_starter[14154]: Attempting to start charon...
  26. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[DMN] Starting IKE charon daemon (strongSwan 5.5.3, Linux 4.14.0-deepin2-amd64, x86_64)
  27. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[CFG] loading ca certificates from '/etc/ipsec.d/cacerts'
  28. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[CFG] loading aa certificates from '/etc/ipsec.d/aacerts'
  29. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[CFG] loading ocsp signer certificates from '/etc/ipsec.d/ocspcerts'
  30. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[CFG] loading attribute certificates from '/etc/ipsec.d/acerts'
  31. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[CFG] loading crls from '/etc/ipsec.d/crls'
  32. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[CFG] loading secrets from '/etc/ipsec.secrets'
  33. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[CFG] expanding file expression '/var/lib/strongswan/ipsec.secrets.inc' failed
  34. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[CFG] loading secrets from '/etc/ipsec.d/nm-l2tp-ipsec-33d8fc19-a978-4ac2-a327-abfa07b5fbb4.secrets'
  35. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[CFG]   loaded IKE secret for %any
  36. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[LIB] loaded plugins: charon aesni aes rc2 sha2 sha1 md5 random nonce x509 revocation constraints pubkey pkcs1 pkcs7 pkcs8 pkcs12 pgp dnskey sshkey pem openssl fips-prf gmp agent xcbc hmac gcm attr kernel-netlink resolve socket-default connmark stroke updown
  37. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[LIB] dropped capabilities, running as uid 0, gid 0
  38. 2月 28 15:46:42 debuggerx-pc charon[14155]: 00[JOB] spawning 16 worker threads
  39. 2月 28 15:46:42 debuggerx-pc ipsec_starter[14154]: charon (14155) started after 20 ms
  40. 2月 28 15:46:42 debuggerx-pc charon[14155]: 05[CFG] received stroke: add connection '33d8fc19-a978-4ac2-a327-abfa07b5fbb4'
  41. 2月 28 15:46:42 debuggerx-pc charon[14155]: 05[CFG] added configuration '33d8fc19-a978-4ac2-a327-abfa07b5fbb4'
  42. 2月 28 15:46:43 debuggerx-pc charon[14155]: 08[CFG] rereading secrets
  43. 2月 28 15:46:43 debuggerx-pc charon[14155]: 08[CFG] loading secrets from '/etc/ipsec.secrets'
  44. 2月 28 15:46:43 debuggerx-pc charon[14155]: 08[CFG] expanding file expression '/var/lib/strongswan/ipsec.secrets.inc' failed
  45. 2月 28 15:46:43 debuggerx-pc charon[14155]: 08[CFG] loading secrets from '/etc/ipsec.d/nm-l2tp-ipsec-33d8fc19-a978-4ac2-a327-abfa07b5fbb4.secrets'
  46. 2月 28 15:46:43 debuggerx-pc charon[14155]: 08[CFG]   loaded IKE secret for %any
  47. 2月 28 15:46:43 debuggerx-pc charon[14155]: 09[CFG] received stroke: initiate '33d8fc19-a978-4ac2-a327-abfa07b5fbb4'
  48. 2月 28 15:46:43 debuggerx-pc charon[14155]: 10[IKE] initiating Main Mode IKE_SA 33d8fc19-a978-4ac2-a327-abfa07b5fbb4[1] to 18.221.140.253
  49. 2月 28 15:46:43 debuggerx-pc charon[14155]: 10[IKE] initiating Main Mode IKE_SA 33d8fc19-a978-4ac2-a327-abfa07b5fbb4[1] to 18.221.140.253
  50. 2月 28 15:46:43 debuggerx-pc charon[14155]: 10[ENC] generating ID_PROT request 0 [ SA V V V V V ]
  51. 2月 28 15:46:43 debuggerx-pc charon[14155]: 10[NET] sending packet: from 10.0.0.227[500] to 18.221.140.253[500] (240 bytes)
  52. 2月 28 15:46:43 debuggerx-pc charon[14155]: 11[NET] received packet: from 18.221.140.253[500] to 10.0.0.227[500] (40 bytes)
  53. 2月 28 15:46:43 debuggerx-pc charon[14155]: 11[ENC] parsed INFORMATIONAL_V1 request 0 [ N(NO_PROP) ]
  54. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]: initiating Main Mode IKE_SA 33d8fc19-a978-4ac2-a327-abfa07b5fbb4[1] to 18.221.140.253
  55. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]: generating ID_PROT request 0 [ SA V V V V V ]
  56. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]: sending packet: from 10.0.0.227[500] to 18.221.140.253[500] (240 bytes)
  57. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]: received packet: from 18.221.140.253[500] to 10.0.0.227[500] (40 bytes)
  58. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]: parsed INFORMATIONAL_V1 request 0 [ N(NO_PROP) ]
  59. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]: received NO_PROPOSAL_CHOSEN error notify
  60. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]: establishing connection '33d8fc19-a978-4ac2-a327-abfa07b5fbb4' failed
  61. 2月 28 15:46:43 debuggerx-pc charon[14155]: 11[IKE] received NO_PROPOSAL_CHOSEN error notify
  62. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]: Stopping strongSwan IPsec...
  63. 2月 28 15:46:43 debuggerx-pc charon[14155]: 00[DMN] signal of type SIGINT received. Shutting down
  64. 2月 28 15:46:43 debuggerx-pc ipsec_starter[14154]: child 14155 (charon) has quit (exit code 0)
  65. 2月 28 15:46:43 debuggerx-pc ipsec_starter[14154]:
  66. 2月 28 15:46:43 debuggerx-pc nm-l2tp-service[14102]: g_dbus_method_invocation_take_error: assertion 'error != NULL' failed
  67. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]:   [1519804003.9757] vpn-connection[0x5641a70574b0,33d8fc19-a978-4ac2-a327-abfa07b5fbb4,"flutter",0]: VPN plugin: state changed: stopped (6)
  68. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]:   [1519804003.9780] vpn-connection[0x5641a70574b0,33d8fc19-a978-4ac2-a327-abfa07b5fbb4,"flutter",0]: VPN service disappeared
  69. 2月 28 15:46:43 debuggerx-pc NetworkManager[908]:   [1519804003.9789] vpn-connection[0x5641a70574b0,33d8fc19-a978-4ac2-a327-abfa07b5fbb4,"flutter",0]: VPN connection: failed to connect: 'Message recipient disconnected from message bus without replying'
Copy the Code


根据这些信息我是没找到什么有用的信息,所以又尝试在vm虚拟机里用centos配置vpn连接结果完全没有问题。几次比较和摸索以后发现有个文件比较可疑,就是位于
/etc/ipsec.d/nm-l2tp-ipsec-33d8fc19-a978-4ac2-a327-abfa07b5fbb4.secrets 这个文件 与centos中生成的 /etc/ipsec.d/ipsec-xxxx-xxxxxx-xxxxxx-xxxx.secrets文件的内容不同,其中centos的内容为:
  1. 18.221.140.253 %any: PSK "fluttertestvpn.com"
Copy the Code
而deepin生成的内容则是:
  1. : PSK "fluttertestvpn.com"
Copy the Code
感觉像是缺失了一部分内容。我尝试修改这个文件,但是每次点击连接的时候它都会被修改刷新,结果还是连接失败,看代码也没找到是哪里在修改这个文件,所以希望相关开发能帮忙看看是不是这里出的问题。

https://bbs.deepin.org/user/48640 https://bbs.deepin.org/user/101846 @https://bbs.deepin.org/user/33235
Reply Favorite View the author
All Replies
1 / 2
To page
aida
deepin
2018-03-01 00:37
#1
Reply View the author
yanbowen
deepin
2018-03-01 01:09
#2
可以给个测试帐号吗?
Reply View the author
DebuggerX
deepin
2018-03-01 01:11
#3
https://bbs.deepin.org/post/153665
可以给个测试帐号吗?

我私信你吧
Reply View the author
yanbowen
deepin
2018-03-01 01:21
#4

恩,原因可能是服务器端使用的加密算法太弱,已经不在strongswan的支持列表中了,我试下吧。
Reply View the author
yanbowen
deepin
2018-03-01 01:45
#5
https://github.com/nm-l2tp/netwo ... algorithm-proposals

上面有查询服务器断加密算法的方法,以及设置合适的客户端算法
Reply View the author
yanbowen
deepin
2018-03-01 19:16
#6

服务器端使用的是弱加密算法导致连接失败的。

在控制中心创建l2tp后,会在/etc/NetworkManager/system-connections/ 下生成对应名称的文件,编辑这个文件,在 [vpn] 段下添加如下2行,指定加密算法:

  1. ipsec-esp=aes128-sha1,3des-md5
  2. ipsec-ike=aes128-sha1-modp1024,3des-sha1-modp1024
Copy the Code
Reply View the author
DebuggerX
deepin
2018-03-01 19:37
#7
https://bbs.deepin.org/post/153665
服务器端使用的是弱加密算法导致连接失败的。

在控制中心创建l2tp后,会在/etc/NetworkManager/system-c ...

添加了还是不行,现在需要什么信息么?
Reply View the author
yanbowen
deepin
2018-03-01 21:03
#8
https://bbs.deepin.org/post/153665
添加了还是不行,现在需要什么信息么?

我试过了,可以啊,添加后重启下
Reply View the author
DebuggerX
deepin
2018-03-01 21:47
#9
https://bbs.deepin.org/post/153665
我试过了,可以啊,添加后重启下

嗯,试了几次之后连接成功了,不知道是不是因为我安装了network-manager-gnome有冲突,中间我把这个卸了然后新建配置加重启后连上了,感谢处理!
顺便问下有计划在后面的更新里加入这个问题的自动处理么?还是说以后也要这样手动指定?而且我还不知道这两行的算法是怎么得到的,昨天运行检测脚本不是输出了很多么,是随便挑的一个就行么?
Reply View the author
yanbowen
deepin
2018-03-01 22:23
#10
https://bbs.deepin.org/post/153665
嗯,试了几次之后连接成功了,不知道是不是因为我安装了network-manager-gnome有冲突,中间我把这个卸了 ...

之后会在控制中心里添加这2项的设置界面,但不会自动填入相应算法。

自动探测算法需要root权限,控制中心做不了,后期可能会给出工具,由用户执行,并将结果填入到控制中心的设置界面。
Reply View the author
DebuggerX
deepin
2018-03-01 22:40
#11
https://bbs.deepin.org/post/153665
之后会在控制中心里添加这2项的设置界面,但不会自动填入相应算法。

自动探测算法需要root权限,控制中 ...

可是检测工具也需要用户有权限去执行才行吧?我这里因为vpn就是我自己申请的主机自己搭建的所以可以搞,一般用户直接买来的vpn或者公司给的vpn怎么办呢?你的意思是其他发行版之所以能够连接是因为它们使用的strongswan版本低对么?那么可以通过设置strongswan的默认配置的方式扩大适用范围么。
又或者给一个自动尝试使用不同算法连接的选项,在失败时提示自动尝试,想跑字典一样把各种加密算法都尝试一下到连接成功?
Reply View the author
yanbowen
deepin
2018-03-02 00:29
#12
https://bbs.deepin.org/post/153665
可是检测工具也需要用户有权限去执行才行吧?我这里因为vpn就是我自己申请的主机自己搭建的所以可以搞, ...

检测工具只需要在客户端执行
Reply View the author
DebuggerX
deepin
2018-03-02 01:13
#13
https://bbs.deepin.org/post/153665
检测工具只需要在客户端执行

明白了,谢谢O(∩_∩)O
Reply View the author
vampires
deepin
2018-05-05 06:44
#14
我的也是没有办法连接  确认预共享密码和账号密码都是正常的 但是连接失败
Reply View the author
qq2848203063
deepin
2018-06-01 06:08
#15
VPN主服务器 + 分服务器 + 网站管理 +流量控制系统
搭建你自己的VPN服务器

http://148.163.171.13:82/VPNSvrSoft.rar

上TB租一个VPS 装个win2003 再装这个系统 就可以用了
使用有问题的联系QQ 2848203063
网上找到免费的,不用谢
Reply View the author
junior_chan
deepin
2019-08-20 00:03
#16
同样的问题,一直连接失败,检测出来应该是AES,256的,怎么改都没法登陆VPN
Reply View the author
kevinlee
deepin
2019-08-22 21:44
#17
https://bbs.deepin.org/post/153665
同样的问题,一直连接失败,检测出来应该是AES,256的,怎么改都没法登陆VPN ...

那要看你的V{忽略}P{忽略}N是不是国外的,如果是国外的,那就已经被网络长城给拦下来了(他不给我们f{忽略}q)。如果是中国的,那么看看是咋回事
Reply View the author
180******69
deepin
2019-08-28 16:47
#18
https://bbs.deepin.org/post/153665
服务器端使用的是弱加密算法导致连接失败的。

在控制中心创建l2tp后,会在/etc/NetworkManager/system-c ...

下面是使用ike-scan.sh的输出,麻烦看看应该如何指定加密算法。谢谢!
  1.         SA=(Enc=3DES Hash=SHA1 Auth=PSK Group=5:modp1536 LifeType=Seconds LifeDuration(4)=0x00007080)
  2.         SA=(Enc=3DES Hash=SHA1 Auth=PSK Group=14:modp2048 LifeType=Seconds LifeDuration(4)=0x00007080)
  3.         SA=(Enc=AES Hash=SHA1 Auth=PSK Group=2:modp1024 KeyLength=128 LifeType=Seconds LifeDuration(4)=0x00007080)
  4.         SA=(Enc=AES Hash=SHA1 Auth=PSK Group=5:modp1536 KeyLength=128 LifeType=Seconds LifeDuration(4)=0x00007080)
  5.         SA=(Enc=AES Hash=SHA1 Auth=PSK Group=14:modp2048 KeyLength=128 LifeType=Seconds LifeDuration(4)=0x00007080)
  6.         SA=(Enc=AES Hash=SHA1 Auth=PSK Group=2:modp1024 KeyLength=192 LifeType=Seconds LifeDuration(4)=0x00007080)
  7.         SA=(Enc=AES Hash=SHA1 Auth=PSK Group=5:modp1536 KeyLength=192 LifeType=Seconds LifeDuration(4)=0x00007080)
  8.         SA=(Enc=AES Hash=SHA1 Auth=PSK Group=14:modp2048 KeyLength=192 LifeType=Seconds LifeDuration(4)=0x00007080)
  9.         SA=(Enc=AES Hash=SHA1 Auth=PSK Group=2:modp1024 KeyLength=256 LifeType=Seconds LifeDuration(4)=0x00007080)
  10.         SA=(Enc=AES Hash=SHA1 Auth=PSK Group=5:modp1536 KeyLength=256 LifeType=Seconds LifeDuration(4)=0x00007080)
  11.         SA=(Enc=AES Hash=SHA1 Auth=PSK Group=14:modp2048 KeyLength=256 LifeType=Seconds LifeDuration(4)=0x00007080)
  12.         SA=(Enc=AES Hash=SHA2-512 Auth=PSK Group=5:modp1536 KeyLength=256 LifeType=Seconds LifeDuration(4)=0x00007080)
  13.         SA=(Enc=AES Hash=SHA2-512 Auth=PSK Group=14:modp2048 KeyLength=256 LifeType=Seconds LifeDuration(4)=0x00007080)
Copy the Code
Reply View the author
yanbowen
deepin
2019-08-28 21:20
#19
https://bbs.deepin.org/post/153665
下面是使用ike-scan.sh的输出,麻烦看看应该如何指定加密算法。谢谢!
  1. Phase1 Algorithms: aes128-sha1-modp1024,3des-sha1-modp1536
  2. Phase2 Algorithms: aes128-sha1,3des-md5
Copy the Code


试下这个,目前控制中心创建 VPN 时可直接指定加密算法
Reply View the author
180******69
deepin
2019-08-29 00:46
#20
https://bbs.deepin.org/post/153665
试下这个,目前控制中心创建 VPN 时可直接指定加密算法

连上了,非常感谢!!
如果有时间,请讲讲如何根据测试结果指定加密算法,方便新手学习。
再次感谢!
Reply View the author
1 / 2
To page