V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
wzxjohn
V2EX  ›  分享创造

说好的不需要客户端证书的 iOS 8 的 IKEv2 On-Demand VPN 教程来了

  •  5
     
  •   wzxjohn · 2014-10-08 18:05:28 +08:00 · 30468 次点击
    这是一个创建于 3493 天前的主题,其中的信息可能已经有所发展或是发生改变。
    因为打字的电脑木有中文输入法,所以先写的英文然后一句句翻的。大家凑合看吧。

    http://maoxian.de/2014/10/setup-ikev2-on-demand-vpn-on-ios-8-and-ikev2-ikev1-cisco-ipsec-vpn-with-strongswan/1220.html

    其中顺便说明了通配符证书的情况。如果大家遇到什么问题欢迎在v2留言,博客留言,email提问。
    顺便一说如果要转载的话麻烦加个链接~谢谢~
    第 1 条附言  ·  2014-10-08 21:04:39 +08:00
    所谓的On Demand就是说在检测到网络变化后,如果你访问了特定的URL系统就会自动连接VPN,基本等同于Always On。
    第 2 条附言  ·  2014-10-08 22:57:02 +08:00
    10/8/2014 22:40 更新了一下Gist,加入了少许注释,帮助大家理解这个配置文件。
    更新了一下文章,添加了对证书的一些解释和注意事项。
    更新一个测试用配置文件,仅限V2EXer使用,服务器在国内,所以没有翻越功能,只是用来测试体验。
    http://maoxian.de/v2ex.mobileconfig
    第 3 条附言  ·  2014-10-09 15:22:31 +08:00
    9/10/2014 15:20 更新了一下文章说了一下关于纯IP的服务器的可能处理方法。因为没有试过所以不能给出完整的解决方案。毕竟这年头没有域名的人太少了,个人感觉没必要为了这个去折腾一些。。。
    更新了一下给mobileconfig文件签名的方法。同时放出一个已签名的配置文件给大家试试:
    http://maoxian.de/v2ex_signed.mobileconfig
    第 4 条附言  ·  2014-10-10 13:59:23 +08:00
    10/10/2014 14:00
    感谢@cattyhouse的测试。文章更新了纯IP的服务端的配置注意事项,现在已经可以搭建没有域名的服务器了。同时感谢他对On Demand配置的修改,之前确实是我偷懒了懒得测试,其实只需要把Action设置为Connect即可无条件连接VPN,效果等同于Always On。Gist已经更新,同时两个测试配置文件已经更新,大家可以通过
    http://maoxian.de/v2ex.mobileconfig
    http://maoxian.de/v2ex_signed.mobileconfig
    来感受一下。
    第 5 条附言  ·  2014-10-12 13:09:31 +08:00
    12/10/2014 13:10 更新文章增加VPN服务的调试方法,教你打开详细的日志。如果遇到无法解决的问题可以尝试打开Level 2的日志,然后一般就能看出问题出在哪了。
    第 6 条附言  ·  2014-10-12 16:19:11 +08:00
    12/10/2014 16:20
    感谢@GPU 的测试,增加了从源码编译时的主意事项,增加了在Debian系统上安装的时候的注意事项。注意在Debian系统上安装的时候请不要使用ufw而是用自带的iptables。
    154 条回复    2015-12-15 13:18:00 +08:00
    1  2  
    gissimo
        101
    gissimo  
       2014-10-25 19:34:38 +08:00
    @goodbest
    @g552656
    @wzxjohn
    @cattyhouse

    再请教下楼主。总结下我的问题:

    其实我的需求很简单,就是不断VPN,锁屏不断就行。请问我ikev1就够了吗?还是必须ikev2?

    vps端,我配置了ikev1和ikev2.


    客户端这里,Windows端,用原生的ikev2,配合EAP-MSCHAPv2
    ios8目前用cisco ipsec完全没问题,但是ikev2始终配置不好。但是cisco锁屏一会儿还是会断。


    是不是需要手动加入ondemand那几句?
    GPU
        102
    GPU  
       2014-10-25 20:52:58 +08:00
    @gissimo window 不能。 但是你可以直接下载楼主的 修改。
    JackWindows
        103
    JackWindows  
       2014-10-25 22:06:29 +08:00
    更正一点:leftid并非需要跟cert中的CN相同,可以写成leftid=@*,亲测可以使用。
    应用场景:证书中签了多个域名(multiple domain),有若干个subAlternative Domains
    wzxjohn
        104
    wzxjohn  
    OP
       2014-10-25 23:03:22 +08:00 via iPhone
    @JackWindows 在我的测试中不匹配会导致某些客户端应为证书不匹配导致服务器验证失败,不知道你是怎么生成证书的?
    @gissimo 你的问题好多,等我明天慢慢回你。。。
    JackWindows
        105
    JackWindows  
       2014-10-26 00:09:04 +08:00
    wzxjohn
        106
    wzxjohn  
    OP
       2014-10-26 00:16:13 +08:00 via iPhone
    @JackWindows 说实话没弄过这种多证书的情况不了解,多域名多线专卖VPN的巨巨就别来鄙视我们这些苦逼屌丝了。。。
    wzxjohn
        107
    wzxjohn  
    OP
       2014-10-26 00:17:23 +08:00 via iPhone
    @JackWindows 说错了,多域名证书。
    JackWindows
        108
    JackWindows  
       2014-10-26 00:58:36 +08:00
    @wzxjohn 你这说法让我很不爽,我只是自己有多线,需要用域名来区分线路而已,咋就莫名其妙变成VPN奸商了???
    wzxjohn
        109
    wzxjohn  
    OP
       2014-10-26 10:06:19 +08:00 via iPhone
    @JackWindows 我啥时候说你是奸商了?另外多线也不需要域名区分,直接DNS解析时返回不同IP就好。
    JackWindows
        110
    JackWindows  
       2014-10-26 11:17:28 +08:00 via iPhone
    @wzxjohn 智能解析当然有做,有个auto的域名。但这东西又不一定靠谱,定的解析规则也有可能不准,最后还不是得多域名。
    wzxjohn
        111
    wzxjohn  
    OP
       2014-10-26 15:14:32 +08:00
    @gissimo
    1. 可以用,我已经在文章里更新了如何自签名纯IP服务器的证书
    2. Windows下的Configurator都多少年没更新了,乖乖换Mac或者手写吧
    3. 我的文章中写的就是eap的教程,没写用证书的情况
    4. 锁屏不知道会不会断,但是断了会自动重连
    5. On Demand需要手动加入,目前IKEv2按照我的方法你是看不到On Demand选项的。至于你的Cisco IPSec锁屏会断我不知道是为什么,没有研究过这个。
    JackWindows
        112
    JackWindows  
       2014-10-26 15:40:17 +08:00
    @wzxjohn 其实建议debug的话直接用ipsec start --nofrok,简单快捷
    JackWindows
        113
    JackWindows  
       2014-10-26 19:08:56 +08:00
    今天又发现一个问题,leftid=@*这句配置跟android下strongswan客户端冲突,所以需要两份配置文件来应对,一份leftid=@*给ios用,一份leftid=ikev2给android用
    hzx1987227
        114
    hzx1987227  
       2014-10-27 01:17:41 +08:00 via iPad
    我发现断开IKEV2的时候,strongswan端并不会收到断开的消息,导致需要等timeout后用户才会被strongswan标记为下线...到底是iOS的bug呢还是strongswan的问题呢...
    hzx1987227
        115
    hzx1987227  
       2014-10-27 01:18:32 +08:00 via iPad
    windows下的ikev2不存在这个bug...不知道是不是个例,最新版的strongswan也一样有问题
    wzxjohn
        116
    wzxjohn  
    OP
       2014-10-27 11:27:27 +08:00
    @hzx1987227 你说的这个问题我也发现了,确实是这样,似乎是strongswan的bug或者是机制?不过没有影响,所以我也就没在意这个。我觉得可能是为了断线快速重连。纯属猜测。因为我发现网络切换的时候重连VPN的时候事实上没有经过第一次连接时候那样的认证过程而是直接重用了之前的链接直接连上了。。。
    hzx1987227
        117
    hzx1987227  
       2014-10-27 14:21:19 +08:00
    @wzxjohn 我测试下来的结果是会多占用一个session,如果VPN有控制账号的session限制的话,会导致无法连接。只有等timeout后才会释放。(测试方法:连接VPN,断开WIFI,连接WIFI,VPN会自动重新连上)
    wzxjohn
        118
    wzxjohn  
    OP
       2014-10-27 16:34:36 +08:00
    @hzx1987227 这个问题已经考虑到了,所以在我的配置文件里特地写明了不限制连接数。
    hzx1987227
        119
    hzx1987227  
       2014-10-27 17:30:59 +08:00
    @wzxjohn 那看来我只能等iOS或者strongswan发现这个问题了 :(
    GPU
        120
    GPU  
       2014-11-07 19:42:27 +08:00
    @wzxjohn 这个strongSwan 怎么弄开机启动的? 在strongSwan wiki 搜 startup boot 都搜不到有用的东西
    jerry74
        121
    jerry74  
       2014-12-05 23:22:03 +08:00
    @wzxjohn blog上的iptables.up.rules 跟ipsec.conf好像不见了
    wzxjohn
        122
    wzxjohn  
    OP
       2014-12-06 00:18:28 +08:00   ❤️ 1
    @jerry74 显示Gist的js被ADB干了,关掉ADB即可。。。在我这是这样的。。。
    jerry74
        123
    jerry74  
       2014-12-06 11:59:19 +08:00
    @wzxjohn chrome关掉就可以了
    ie啥都没装也显示不出来....
    wzxjohn
        124
    wzxjohn  
    OP
       2014-12-06 12:05:39 +08:00
    @jerry74 我的博客就没准备支持任何版本的IE。。。
    thekll
        125
    thekll  
       2014-12-23 04:23:50 +08:00
    @wzxjohn
    教程中ipsec.conf设置推给客户端的dns是8.8.4.4,如果我在服务器本机配置了dnsmasq,并且想让客户端使用服务端的dns,应该如何设置?
    另外,我的os x版本还是10.8,无法安装Apple Configurator,有没有其他办法导入mobileconfig?
    wzxjohn
        126
    wzxjohn  
    OP
       2014-12-23 09:50:50 +08:00
    @thekll 1. 把 rightdns=8.8.8.8,8.8.4.4 直接改了就可以。
    2. 那个配置文件就是个明文的XML文件,直接下我的未签名版用任何文本编辑器打开改就可以了。签名版不能直接改因为修改之后签名会失效。所以直接下未签名的改了如果需要签名再自己签一下就可以了。
    thekll
        127
    thekll  
       2014-12-23 11:45:58 +08:00
    @wzxjohn
    第一个问题我可能没说清,不知道rightdns的ip应该改为哪个ip,vps的外网ip?实际上dnsmasq我设置是在127.0.0.1上侦听,我希望这个dns只在vpn内部可用,那对于客户端来说,vpn服务端的内部ip是什么?
    我尝试修改ipsec.conf:
    ...
    leftsubnet=10.6.0.0/24
    ...
    rightdns=10.6.0.1
    rightsourceip=10.7.0.0/16

    然后ios7通过cisco ipsec连接vpn,ios上可以看到vpn接口上的dns已经是10.6.0.1(scutil --dns,ios已越狱),终端模式下也可以向此ip发nslookup命令,解析正常,但是其他应用都无法解析域名,包括浏览器,不知何故。
    Caixiaopig
        128
    Caixiaopig  
       2015-01-11 11:26:24 +08:00
    ikev1的话,能够配置成使用startssl之类颁发的SSL证书的方式吗?目前只有配置自签名证书才能成功。
    ikev2,安装楼主的教程已经成功了,客户端不需要任何证书,只要你在strongswan上有一个CA认证的服务器证书即可。但是ikev2的ios8的bug有点不能接受啊。求IKEv1下,客户端免导入证书的配置(主要是ipsec.conf和apple的mobileconfig)
    weiyu99
        129
    weiyu99  
       2015-01-24 11:28:03 +08:00
    @Caixiaopig 能把你成功的ipsec.con 关于 ikev2 这部份发给我参考一下吗?照著楼主教程过了 server 端认证就停了....
    wzxjohn
        130
    wzxjohn  
    OP
       2015-01-24 11:35:32 +08:00 via iPhone
    @weiyu99 你有输出 Log 看看问题么?把日志贴出来看下吧。
    weiyu99
        131
    weiyu99  
       2015-01-24 11:45:15 +08:00
    @wzxjohn

    Sat Jan 24 11:22:39 2015 daemon.info syslog: 07[IKE] authentication of '220.134.xxx.xxx' (myself) with RSA signature successful
    Sat Jan 24 11:22:39 2015 daemon.info syslog: 07[IKE] sending end entity cert "C=CH, O=TheBelle, CN=220.134.xxx.xxx"
    Sat Jan 24 11:22:39 2015 daemon.info syslog: 07[ENC] generating IKE_AUTH response 1 [ IDr CERT AUTH EAP/REQ/ID ]
    Sat Jan 24 11:22:39 2015 daemon.info syslog: 07[NET] sending packet: from 220.134.xxx.xxx[4500] to 116.192.26.218[1025] (1228 bytes)
    Sat Jan 24 11:22:39 2015 daemon.info syslog: 09[NET] sending packet: from 220.134.xxx.xx[4500] to 116.192.26.218[1025]
    Sat Jan 24 11:22:39 2015 daemon.info syslog: 07[MGR] checkin IKE_SA IPSec-IKEv2-EAP[1]
    Sat Jan 24 11:22:39 2015 daemon.info syslog: 07[MGR] check-in of IKE_SA successful.
    Sat Jan 24 11:23:09 2015 daemon.info syslog: 13[MGR] checkout IKE_SA
    Sat Jan 24 11:23:09 2015 daemon.info syslog: 13[MGR] IKE_SA IPSec-IKEv2-EAP[1] successfully checked out
    Sat Jan 24 11:23:09 2015 daemon.info syslog: 13[JOB] deleting half open IKE_SA after timeout
    Sat Jan 24 11:23:09 2015 daemon.info syslog: 13[MGR] checkin and destroy IKE_SA IPSec-IKEv2-EAP[1]
    Sat Jan 24 11:23:09 2015 daemon.info syslog: 13[IKE] IKE_SA IPSec-IKEv2-EAP[1] state change: CONNECTING => DESTROYING
    Sat Jan 24 11:23:09 2015 daemon.info syslog: 13[MGR] check-in and destroy of IKE_SA successful
    weiyu99
        132
    weiyu99  
       2015-01-24 11:50:08 +08:00
    @wzxjohn

    Sat Jan 24 11:22:39 2015 daemon.info syslog: 07[IKE] authentication of '220.134.xxx.xxx' (myself) with RSA signature successful

    这段 log 是指server认证成功是吧?
    wzxjohn
        133
    wzxjohn  
    OP
       2015-01-24 12:10:12 +08:00
    @weiyu99 当然不是,这段说的是使用 RSA 证书认证自己成功,也就是服务端读取证书成功而已。
    你的问题出在这:
    Sat Jan 24 11:22:39 2015 daemon.info syslog: 07[MGR] check-in of IKE_SA successful.
    Sat Jan 24 11:23:09 2015 daemon.info syslog: 13[MGR] checkout IKE_SA
    因为超时 30 秒,连接被断开了。
    顺便你的 Log 似乎不够详细,按照我文章里说的把调试开关都打开看看?
    weiyu99
        134
    weiyu99  
       2015-01-24 13:31:49 +08:00
    @wzxjohn 这是我 ipsec.conf 里面的设置:

    config setup
    # strictcrlpolicy=yes
    uniqueids = no
    charondebug="ike 2, knl 2, cfg 2, net 2, esp 2, dmn 2, mgr 2"

    conn %default
    keyexchange=ikev2
    dpdaction=clear
    dpddelay=6s
    rekey=no
    leftcert=xxxServerCert.pem
    leftsendcert=always
    left=%any
    leftsubnet=0.0.0.0/0
    right=%any
    rightdns=8.8.8.8,8.8.4.4
    rightsourceip=192.168.2.0/24


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


    这是我的 log file: 有点长,把前面可能不重要的地方都删了

    Sat Jan 24 13:07:32 2015 daemon.info syslog: 16[IKE] remote host is behind NAT
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 16[IKE] sending cert request for "C=CH, O=TheBelle, CN=strongSwan Root CA"
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 16[ENC] generating IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) CERTREQ N(MULT_AUTH) ]
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 16[NET] sending packet: from 220.134.xxx.xxx[500] to 116.192.26.218[500] (333 bytes)
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 06[NET] sending packet: from 220.134.xxx.xxx[500] to 116.192.26.218[500]
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 16[MGR] checkin IKE_SA (unnamed)[2]
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 16[MGR] check-in of IKE_SA successful.
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 05[NET] received packet: from 116.192.26.218[4500] to 220.134.xxx.xxx[4500]
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 05[NET] waiting for data on sockets
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[MGR] checkout IKE_SA by message
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[MGR] IKE_SA (unnamed)[2] successfully checked out
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[NET] received packet: from 116.192.26.218[4500] to 220.134.xxx.xxx[4500] (340 bytes)
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[ENC] parsed IKE_AUTH request 1 [ IDi N(INIT_CONTACT) IDr CPRQ(ADDR DHCP DNS MASK ADDR6 DHCP6 DNS6) N(ESP_TFC_PAD_N) N(NON_FIRST_FRAG) SA TSi TSr ]
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[CFG] looking for peer configs matching 220.134.224.251[xxx.xxx.xxx]...116.192.26.218[[email protected]]
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[CFG] candidate "IPSec-IKEv2", match: 20/20/28 (me/other/ike)
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[CFG] candidate "IPSec-IKEv2-EAP", match: 20/20/28 (me/other/ike)
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[CFG] selected peer config 'IPSec-IKEv2'
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] peer requested EAP, config inacceptable
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[CFG] switching to peer config 'IPSec-IKEv2-EAP'
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] initiating EAP_IDENTITY method (id 0x00)
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] processing INTERNAL_IP4_ADDRESS attribute
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] processing INTERNAL_IP4_DHCP attribute
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] processing INTERNAL_IP4_DNS attribute
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] processing INTERNAL_IP4_NETMASK attribute
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] processing INTERNAL_IP6_ADDRESS attribute
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] processing INTERNAL_IP6_DHCP attribute
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] processing INTERNAL_IP6_DNS attribute
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] received ESP_TFC_PADDING_NOT_SUPPORTED, not using ESPv3 TFC padding
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] authentication of 'xxx.xxx.xxx' (myself) with RSA signature successful
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[IKE] sending end entity cert "C=CH, O=TheBelle, CN=220.134.xxx.xxx"
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[ENC] generating IKE_AUTH response 1 [ IDr CERT AUTH EAP/REQ/ID ]
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[NET] sending packet: from 220.134.xxx.xxx[4500] to 116.192.26.218[4500] (1244 bytes)
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 06[NET] sending packet: from 220.134.xxx.xxx[4500] to 116.192.26.218[4500]
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[MGR] checkin IKE_SA IPSec-IKEv2-EAP[2]
    Sat Jan 24 13:07:32 2015 daemon.info syslog: 13[MGR] check-in of IKE_SA successful.
    Sat Jan 24 13:08:02 2015 daemon.info syslog: 15[MGR] checkout IKE_SA
    Sat Jan 24 13:08:02 2015 daemon.info syslog: 15[MGR] IKE_SA IPSec-IKEv2-EAP[2] successfully checked out
    Sat Jan 24 13:08:02 2015 daemon.info syslog: 15[JOB] deleting half open IKE_SA after timeout
    Sat Jan 24 13:08:02 2015 daemon.info syslog: 15[MGR] checkin and destroy IKE_SA IPSec-IKEv2-EAP[2]
    Sat Jan 24 13:08:02 2015 daemon.info syslog: 15[IKE] IKE_SA IPSec-IKEv2-EAP[2] state change: CONNECTING => DESTROYING
    Sat Jan 24 13:08:02 2015 daemon.info syslog: 15[MGR] check-in and destroy of IKE_SA successful

    帮我看看问题出在哪了...谢谢!
    wzxjohn
        135
    wzxjohn  
    OP
       2015-01-24 13:53:04 +08:00
    @weiyu99 你的配置文件压根没写全,怎么可能能用。。。。。。。。。
    weiyu99
        136
    weiyu99  
       2015-01-24 14:29:43 +08:00
    @wzxjohn sorry, 漏了一部分:

    # ipsec.conf - strongSwan IPsec configuration file

    # basic configuration

    config setup
    # strictcrlpolicy=yes
    uniqueids = no
    charondebug="ike 2, knl 2, cfg 2, net 2, esp 2, dmn 2, mgr 2"

    conn %default
    keyexchange=ikev2
    dpdaction=clear
    dpddelay=6s
    dpdtimeout = 5s
    rekey=no
    leftcert=xxxServerCert.pem
    leftsendcert=always
    left=%any
    leftsubnet=0.0.0.0/0
    right=%any
    rightdns=8.8.8.8,8.8.4.4
    rightsourceip=192.168.2.0/24


    conn IPSec-IKEv2
    keyexchange=ikev2
    [email protected]
    #your servr name in cert "server.pem"
    [email protected]
    #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
    lavarong
        137
    lavarong  
       2015-03-11 17:00:44 +08:00
    专业,mark
    lavarong
        138
    lavarong  
       2015-03-23 15:03:39 +08:00
    @weiyu99 跟我的错误一样,你解决了吗?
    lostff
        139
    lostff  
       2015-04-07 15:15:08 +08:00
    发现这里是难得的国内讨论ios8/ikev2的地方,非常激动。
    言归正传:
    我现在搭建的环境ios只能用ikev1,因为我们需要同时用两种认证方式:
    rightauth=pubkey
    rightauth2=xauth-radius
    也就是同时用证书和口令/用户,相应的在ios端安装的profile也会指定他们
    ios8出来后尝试单独配置证书或者口令/用户,都可以连得通
    但是一起用就不行,咨询过strongswan,答复是ios不支持
    对于以上的困境,各位高人有何建议呢?
    lostff
        140
    lostff  
       2015-04-08 10:07:07 +08:00
    具体只用一种认证方式的配置是按官网上的例子配的
    https://wiki.strongswan.org/projects/strongswan/wiki/AppleIKEv2Profile
    digimoon
        141
    digimoon  
       2015-04-15 17:08:33 +08:00
    @thekll
    我也有相同的问题,客户端不能使用vpn服务器的dnsmasq
    leftsubnet=0.0.0.0/0,rightsourceip=10.0.0.0/24,设置rightdns=192.168.1.1,服务器有一个内网能访问的ip 192.168.1.1而且iptables也是全放行的,
    vpn连上后能访问192.168.1.0/24的设备,用ios的inet tools扫描192.168.1.1的ssh端口显示打开,扫描53端口显示关闭(估计只扫描tcp?),直接输入ip能上网但是输入网址的话就打开不了应该就是dns问题
    不知道你找到解决办法没有?
    freefall12
        142
    freefall12  
       2015-05-24 18:53:58 +08:00
    @digimoon
    DNS服务器可以在strongswan.conf里面添加,charon.dns1 = x.x.x.x,charon.dns2 = x.x.x.x

    想用IOS ikev2又不想折腾的可到此看下,https://www.joyvm.com/ios-oneclick-vpn-setuup
    wzxjohn
        143
    wzxjohn  
    OP
       2015-05-25 08:49:19 +08:00
    @freefall12 我就知道公开了方法就会有人拿来卖。。。你卖就卖吧还回原帖打广告。。。
    Remember
        144
    Remember  
       2015-07-11 18:11:36 +08:00
    这个有办法同时支持L2TP/IPsec么?
    jameszeng
        145
    jameszeng  
       2015-07-16 22:25:52 +08:00
    我在ikev1下配置了unity plugin的split tunneling,国外网站访问不了,日志里有这样的错误:
    Jul 15 10:12:14 default charon: 01[KNL] getting a local address in traffic selector 8.8.8.0/24
    Jul 15 10:12:14 default charon: 01[KNL] no local address found in traffic selector 8.8.8.0/24
    Jul 15 10:12:14 default charon: 01[KNL] error installing route with policy 8.8.8.0/24 === 192.168.12.1/32 out
    Jul 15 10:12:14 default charon: 01[KNL] getting a local address in traffic selector 8.8.8.0/24
    Jul 15 10:12:14 default charon: 01[KNL] no local address found in traffic selector 8.8.8.0/24
    Jul 15 10:12:14 default charon: 01[KNL] error installing route with policy 8.8.8.0/24 === 192.168.12.1/32 out
    Jul 15 10:12:14 default charon: 01[IKE] unable to install IPsec policies (SPD) in kernel
    不知道是什么原因,我用的是iOS 8.4
    mac2man
        146
    mac2man  
       2015-07-17 16:18:16 +08:00
    自签的证书,在IOS端是否需要导入CA证书呢?
    感觉IPHONE不认,无法通过验证。

    14[ENC] generating IKE_AUTH response 1 [ IDr CERT AUTH EAP/REQ/ID ]
    14[NET] sending packet: from server_domain[4500] to client_ip[4500] (1476 bytes)
    06[NET] sending packet: from server_domain[4500] to client_ip[4500]
    03[JOB] deleting half open IKE_SA after timeout
    03[IKE] IKE_SA IPSec-IKEv2-EAP[4] state change: CONNECTING => DESTROYING
    02[JOB] deleting half open IKE_SA after timeout
    02[IKE] IKE_SA IPSec-IKEv2-EAP[5] state change: CONNECTING => DESTROYING
    wzxjohn
        147
    wzxjohn  
    OP
       2015-07-17 16:41:30 +08:00
    @jameszeng 你这个看起来是内核少模块啊。。。
    @mac2man 自签的当然要导入,不然肯定不认的。。。
    mac2man
        148
    mac2man  
       2015-07-17 17:20:00 +08:00
    @wzxjohn 我在windows8上是同样的错误现象 错误码是 13801 确实是需要导入证书,所以判断iphone上需要导入自签证书。
    我倒是有startssl的证书,但是加载不了,是否有使用startssl的方法?
    wzxjohn
        149
    wzxjohn  
    OP
       2015-07-17 18:42:17 +08:00
    @mac2man 我的文章里写了怎么导入证书呀?直接照做就可以了。
    mac2man
        150
    mac2man  
       2015-07-17 19:03:23 +08:00
    @wzxjohn 我现在自签是成功了,但是有奇怪的现象:
    用自签证书搭了ikev2,ios8.2, 很奇怪的现象就是无法正常上下线。
    现象是:客户端已经执行了下线,服务器根本未收到下线请求,还在发dpd报文,必须等待time out后,用户上线才能正常使用。
    Remember
        151
    Remember  
       2015-07-19 00:37:22 +08:00
    @mac2man startssl 你还要加载中间证书,不然windows也会提示13801
    casper8016
        152
    casper8016  
       2015-08-12 19:34:49 +08:00
    @wzxjohn 请问一下 我按照这个配置 连接 IOS8 手机也安装了ca clinet 证书
    但服务器输出
    Aug 12 11:31:12 localhost strongswan: 16[IKE] 223.223.193.58 is initiating an IKE_SA
    Aug 12 11:31:12 localhost strongswan: 16[IKE] IKE_SA (unnamed)[7] state change: CREATED => CONNECTING
    Aug 12 11:31:12 localhost strongswan: 16[CFG] selecting proposal:
    Aug 12 11:31:12 localhost strongswan: 16[CFG] no acceptable ENCRYPTION_ALGORITHM found
    Aug 12 11:31:12 localhost strongswan: 16[CFG] selecting proposal:
    Aug 12 11:31:12 localhost strongswan: 16[CFG] no acceptable DIFFIE_HELLMAN_GROUP found
    Aug 12 11:31:12 localhost strongswan: 16[CFG] selecting proposal:
    Aug 12 11:31:12 localhost strongswan: 16[CFG] proposal matches
    Aug 12 11:31:12 localhost strongswan: 16[CFG] received proposals: IKE:3DES_CBC/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024
    Aug 12 11:31:23 localhost charon: 05[JOB] deleting half open IKE_SA after timeout
    Aug 12 11:31:23 localhost charon: 05[IKE] IKE_SA (unnamed)[6] state change: CONNECTING => DESTROYING
    Aug 12 11:31:42 localhost charon: 02[JOB] deleting half open IKE_SA after timeout
    Aug 12 11:31:42 localhost charon: 02[IKE] IKE_SA (unnamed)[7] state change: CONNECTING => DESTROYING


    是 这个 no acceptable ENCRYPTION_ALGORITHM found 导致 没有连接的原因吗?
    附上我的ipsec.conf
    conn %default
    keyexchange=ikev2
    dpdaction=clear
    dpddelay=5s
    #auto destroy unused connections
    rekey=no
    left=%any
    leftsubnet=0.0.0.0/0
    leftcert=serverCert.pem
    #server cert that will send to client
    leftsendcert=always
    #always send server cert
    #not set may cause cert failed
    right=%any
    rightdns=8.8.8.8,8.8.4.4
    #DNS send to client
    rightsourceip=172.0.0.0/24
    #DHCP Pool for client
    conn IPSec-IKEv2
    keyexchange=ikev2
    leftid=106.187.42.230
    #your servr name in cert "server.pem"
    rightid=*@106.187.42.230
    #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
    monk
        153
    monk  
       2015-09-16 01:14:05 +08:00
    @wzxjohn 怎么删了呢
    wximeng
        154
    wximeng  
       2015-12-15 13:18:00 +08:00
    @wzxjohn 如果使用纯 IP 的服务器,自签的证书要导入 iOS 吗?
    申请一个公网证书, iOS 就不需要导入证书了吗?
    1  2  
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2310 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 03:20 · PVG 11:20 · LAX 20:20 · JFK 23:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.