V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
thidnh
V2EX  ›  问与答

Strongswan 的 ikev2, Windows 发起连接,服务器总是分配到黑莓那个 conn 配置。致使电脑直接死机

  •  
  •   thidnh · 2014-12-07 00:24:02 +08:00 · 7652 次点击
    这是一个创建于 3428 天前的主题,其中的信息可能已经有所发展或是发生改变。
    conn rem
    keyexchange=ikev2
    leftauth=psk
    leftid=抹去
    rightauth=eap-mschapv2
    rightsendcert=never
    eap_identity=%any
    auto=add

    conn windows
    keyexchange=ikev2
    ike=aes256-sha1-modp1024!
    rekey=no
    left=%defaultroute
    leftauth=pubkey
    leftcert=serverCert.pem
    leftsendcert=always
    rightauth=eap-mschapv2
    rightsourceip=172.0.0.0/24
    rightsendcert=never
    eap_identity=%any
    auto=add


    上面那个是给黑莓的,下面是Windows的。我查看日志,Windows发起连接后,服务器直接分配到黑莓那个conn。请问这应该怎么解决啊
    @cattyhouse
    @Luzifer
    @aeshfawre
    @mortal
    @vision92
    @764664
    @jasontse
    36 条回复    2015-07-12 01:22:10 +08:00
    rex1901
        1
    rex1901  
       2014-12-07 11:53:57 +08:00
    我记得ikev2 left强制要求pubkey
    黑莓那个应该是ikev1吧,我不用黑莓,猜的。
    thidnh
        2
    thidnh  
    OP
       2014-12-07 12:26:44 +08:00
    @rex1901 我现在状态是黑莓正常连接。 Windows下报错,查日志,系统分配到了黑莓那个conn
    Luzifer
        3
    Luzifer  
       2014-12-07 16:50:26 +08:00
    我不会比你更了解StrongSwan. 我也入过这个坑.

    如果你是被我带沟里的话,这里说明下:
    黑莓客户端没法导入自制证书(但是可以使用受信任证书, COMODO等)
    所以我直接用psk+eap-mschapv2.
    我脚本里自制证书都省了,ios+android+window都是使用ikev1,‘authby=’是过时的,还没改leftauth
    够简单够粗暴!

    ####以下是瞎掰

    ——————原因, 我不知道, 无责任瞎掰:
    你给出的两个conn,客户端认证rightauth完全一样,
    StrongSwan不知道怎么选服务器认证方式leftauth,
    你黑莓conn直接指定了leftid,所以就分配到黑莓去了.
    如果在namecheap买个ssl证书(COMODO)安装到服务器上,
    估计黑莓就可以使用 证书+eap-mschapv2 验证了(没测试),就和你的 conn windows 使用一个配置了.

    ——————解决办法, 我知道, 无责任乱扯:
    一, 买ssl证书, 黑莓使用<证书+eap-mschapv2> 参见 Astrill 的 IKEv2
    或者
    <证书+eap-tls>,黑莓客户端eap-tls就可以用上受信任证书, WP8.1也可以用这个方式
    (WP8.1 和 黑莓 比, 它是可以导入证书的).

    ####以上是瞎掰

    二,windows 7 直接使用Ikev1 :Shrew on Windows
    三,windows 7 直接使用证书(自制的) :Windows 7 cert mode
    二和三,我都实验通过了。参见
    https://zh.opensuse.org/index.php?title=SDB:Setup_Ipsec_VPN_with_Strongswan&variant=zh

    V2的排版挺瞎的,将就看吧. 好不容易遇到一个莓友在折腾这个.
    里的配置.
    Luzifer
        4
    Luzifer  
       2014-12-07 17:43:41 +08:00
    上面瞎掰有误》

    黑莓是可以导入证书的.
    安全和隐私 > 证书 > 导入

    用户可以在 BlackBerry 设备上使用证书进行 EAP 身份验证。
    Luzifer
        5
    Luzifer  
       2014-12-07 17:49:27 +08:00
    上面扯那么多,错误的知识错误的结果.

    二,windows 7 直接使用Ikev1 :Shrew on Windows
    三,windows 7 直接使用证书(自制的) :Windows 7 cert mode

    就这吧,我再研究研究
    Luzifer
        6
    Luzifer  
       2014-12-07 18:37:58 +08:00
    姿势可以更新了,黑莓可以导入证书, 去掉黑莓那个conn, 黑莓和你的 conn windows 使用一个配置
    thidnh
        7
    thidnh  
    OP
       2014-12-07 18:47:43 +08:00
    @Luzifer 太感谢。想请教下3)中的Windows 7 cert模式是具体指什么模式?Windows 下可以用自带的ikev2吗?
    thidnh
        8
    thidnh  
    OP
       2014-12-07 18:48:29 +08:00
    @Luzifer 啥?可以导入自制证书了?
    Luzifer
        9
    Luzifer  
       2014-12-07 18:58:48 +08:00
    @thidnh 嗯, 导入的应该是自制的 caCert.pem,
    我看的是
    http://www.wpapps.com.cn/skill/1150.html
    WP8.1预览版VPN设置图文教程, 它使用的就是你的 conn windows

    在黑莓上看了下, 网关身份验证类型 PKI
    然后 网关CA证书* 里选导入的 caCert.pem
    应该就是这样了.
    Luzifer
        10
    Luzifer  
       2014-12-07 19:05:26 +08:00   ❤️ 1
    @thidnh 7楼, https://zh.opensuse.org/index.php?title=SDB:Setup_Ipsec_VPN_with_Strongswan&variant=zh

    想请教下3)中的Windows 7 cert模式是具体指什么模式?
    ```
    # and Windows 7 cert mode.
    conn networkmanager-strongswan
    keyexchange=ikev2
    left=%defaultroute
    leftauth=pubkey
    leftsubnet=0.0.0.0/0
    leftcert=server.cert.pem
    right=%any
    rightauth=pubkey
    rightsourceip=10.0.0.0/24
    rightcert=client.cert.pem
    auto=add
    ```
    这一段.

    Windows 下可以用自带的ikev2吗?

    看 ‘其它客户端配置’ 里的 ‘Windows 7+’ 那段. 使用自带客户端(Agile)里有写
    client.cert.p12
    thidnh
        11
    thidnh  
    OP
       2014-12-07 19:07:14 +08:00 via iPhone
    @Luzifer 求加霉友bbm
    thidnh
        12
    thidnh  
    OP
       2014-12-07 19:11:43 +08:00 via iPhone
    @Luzifer pki轻松搞定。太感谢
    Luzifer
        13
    Luzifer  
       2014-12-07 19:14:04 +08:00
    @thidnh PKI搞定了? 9楼方法?
    thidnh
        14
    thidnh  
    OP
       2014-12-07 19:18:52 +08:00
    @Luzifer 对,pki
    Luzifer
        15
    Luzifer  
       2014-12-07 19:25:53 +08:00
    我一直以为黑莓不能导入自制证书,这个错误前提下我就一直没考虑过以证书认证.
    哈哈, 多谢, 知识更新了. 去修改配置去了.
    握手握手, BBM上没人啊,没怎么用. 就不贴了.
    thidnh
        16
    thidnh  
    OP
       2014-12-07 20:52:07 +08:00 via iPhone
    @Luzifer opensuse那篇是你写的?
    Luzifer
        17
    Luzifer  
       2014-12-07 21:02:52 +08:00
    @thidnh 肯定不是啊。没那能耐。
    thidnh
        18
    thidnh  
    OP
       2014-12-07 21:17:45 +08:00 via iPhone
    @Luzifer iOS你能实现锁屏永远不断么?黑莓给我的最大惊喜就是完全不断线啊!!只要连上网络就能自动连接
    Luzifer
        19
    Luzifer  
       2014-12-07 22:06:21 +08:00
    @thidnh 😱 我不会啊. 这不是StrongSwan的问题吧.
    看别人说过Cisco Anyconnect. 不了解. 你可以查了看看.
    以后看到了再回你吧.
    thidnh
        20
    thidnh  
    OP
       2014-12-07 22:17:26 +08:00
    @Luzifer anyconnect我也深入研究了,一起搭建了。确实不断。但速度慢。
    Luzifer
        21
    Luzifer  
       2014-12-07 23:00:09 +08:00
    @thidnh 回 18 楼, 你的ipsec.conf配置里ios是使用 IKEv1 吧.

    https://wiki.strongswan.org/projects/strongswan/wiki/AppleIKEv2Profile

    看了眼WIKI,While iOS 8 and Mac OS X 10.10 now natively support IKEv2, the VPN application's GUI has not yet been updated to allow configuration of such connections on the devices themselves. 原生支持IKEv2.

    可以实验下,IKEv2下锁屏会不会断.

    /t/137653 @wzxjohn 他说“所谓的On Demand就是说在检测到网络变化后,如果你访问了特定的URL系统就会自动连接VPN,基本等同于Always On。”

    他在111楼回复 “4. 锁屏不知道会不会断,但是断了会自动重连”

    你可以问问 @wzxjohn iOS锁屏会不会断。

    我看 @wzxjohn 实验了 eap-mschapv2 。
    wiki里还有Certificate --- EAP-TLS --- Pre-shared key (PSK) 认证。

    可以都试试。 我的设备是黑莓, 苹果是女王大人的, 没空闲时间给我测。😼
    多设备还是路由翻省事。嚯嚯
    thidnh
        22
    thidnh  
    OP
       2014-12-07 23:03:35 +08:00 via iPhone
    @Luzifer 黑莓做主力手机?很多不方便啊,软件没有。最近被last pass搞死,每次打开都要输密码
    thidnh
        23
    thidnh  
    OP
       2014-12-07 23:04:27 +08:00 via iPhone
    @Luzifer 这个关键是我没Mac,没法写profile,win下写不了
    Luzifer
        24
    Luzifer  
       2014-12-07 23:22:39 +08:00
    咱是商务人士。😲 😲 😲
    玩笑话.
    我就电话(国内联系人),邮件(国外联系人).
    对我来说, 就没有比黑莓更好的了. 晚上不回家不担心第二天没电, 这点秒杀其他.
    Luzifer
        25
    Luzifer  
       2014-12-07 23:28:20 +08:00
    @thidnh 那个配置文件不是记事本就可以写的么?
    thidnh
        26
    thidnh  
    OP
       2014-12-07 23:34:08 +08:00 via iPhone
    @Luzifer 不太会写,写了两天都没成功。放弃了
    Luzifer
        27
    Luzifer  
       2014-12-07 23:50:00 +08:00
    @thidnh 你不会我更不会了. 密密麻麻的.


    晚安了。
    wzxjohn
        28
    wzxjohn  
       2014-12-08 00:26:14 +08:00 via iPhone   ❤️ 1
    @thidnh profile就是个xml,你下了我的直接改了服务器地址用户名密码就可以了。
    @Luzifer 我的手机锁屏时候有时候Wifi都断,所以我也不确定到底锁屏会不会断。。。
    thidnh
        29
    thidnh  
    OP
       2014-12-08 11:38:45 +08:00
    @wzxjohn 请教你ios上用的ikev2是下面哪个配置啊

    conn IPSec-IKEv2
    keyexchange=ikev2
    [email protected]
    #your servr name in cert "server.pem"
    rightid=*@every.string.you.want
    #define a suffix for user account
    auto=add

    conn IPSec-IKEv2-EAP
    also="IPSec-IKEv2"
    rightauth=eap-mschapv2
    #define auth type to EAP
    rightsendcert=never
    #do not need client cert
    eap_identity=%any
    #any user can login successfully
    thidnh
        30
    thidnh  
    OP
       2014-12-08 11:41:57 +08:00
    @wzxjohn 瞄了眼看到了[email protected],似乎是conn IPSec-IKEv2这个吧?再请问rightid=*@every.string.you.want里面的*是随意字符还是就保留*
    fuck010bj
        31
    fuck010bj  
       2014-12-08 12:45:02 +08:00
    leftid 和esp没设置
    wzxjohn
        32
    wzxjohn  
       2014-12-08 13:04:46 +08:00 via iPhone
    @thidnh 两个都可以,一个是证书认证一个是EAP认证,只是认证方法不一样。
    @thidnh *是任意字符的意思,配置文件原生支持通配符。
    thidnh
        33
    thidnh  
    OP
       2014-12-08 13:26:46 +08:00
    @wzxjohn 报错

    12[CFG] looking for peer configs matching 抹去IP[抹去域名]...抹去IP[抹去第一个用户名@IPSec]
    12[CFG] no matching peer config found
    thidnh
        34
    thidnh  
    OP
       2014-12-08 13:29:02 +08:00
    @wzxjohn 总结下,我服务器ipsec.conf和你改成一模一样,ios配置文件下载你的,改了用户名 密码 两个域名。

    1.请问你的配置文件走的是哪个conn?
    2.报错,麻烦看下原因。多谢

    12[CFG] looking for peer configs matching 抹去IP[抹去域名]...抹去IP[抹去第一个用户名@IPSec]
    12[CFG] no matching peer config found
    thidnh
        35
    thidnh  
    OP
       2014-12-08 13:34:19 +08:00
    @wzxjohn 附上我的配置文件。@域名中确定要保留@是吧? 我 rightid=*@IPSec可以?

    conn IPSec-IKEv2
    keyexchange=ikev2
    leftid=@域名
    rightid=*@IPSec
    auto=add

    conn IPSec-IKEv2-EAP
    also="IPSec-IKEv2"
    rightauth=eap-mschapv2
    #define auth type to EAP
    rightsendcert=never
    #do not need client cert
    eap_identity=%any
    #any user can login successfully
    Remember
        36
    Remember  
       2015-07-12 01:22:10 +08:00
    @wzxjohn
    @thidnh

    所以rightid 应该怎么设置?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2848 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 15:05 · PVG 23:05 · LAX 08:05 · JFK 11:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.