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

2014-10-08 18:05:28 +08:00
 wzxjohn
因为打字的电脑木有中文输入法,所以先写的英文然后一句句翻的。大家凑合看吧。

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提问。
顺便一说如果要转载的话麻烦加个链接~谢谢~
31099 次点击
所在节点    分享创造
154 条回复
jerry74
2014-12-05 23:22:03 +08:00
@wzxjohn blog上的iptables.up.rules 跟ipsec.conf好像不见了
wzxjohn
2014-12-06 00:18:28 +08:00
@jerry74 显示Gist的js被ADB干了,关掉ADB即可。。。在我这是这样的。。。
jerry74
2014-12-06 11:59:19 +08:00
@wzxjohn chrome关掉就可以了
ie啥都没装也显示不出来....
wzxjohn
2014-12-06 12:05:39 +08:00
@jerry74 我的博客就没准备支持任何版本的IE。。。
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
2014-12-23 09:50:50 +08:00
@thekll 1. 把 rightdns=8.8.8.8,8.8.4.4 直接改了就可以。
2. 那个配置文件就是个明文的XML文件,直接下我的未签名版用任何文本编辑器打开改就可以了。签名版不能直接改因为修改之后签名会失效。所以直接下未签名的改了如果需要签名再自己签一下就可以了。
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
2015-01-11 11:26:24 +08:00
ikev1的话,能够配置成使用startssl之类颁发的SSL证书的方式吗?目前只有配置自签名证书才能成功。
ikev2,安装楼主的教程已经成功了,客户端不需要任何证书,只要你在strongswan上有一个CA认证的服务器证书即可。但是ikev2的ios8的bug有点不能接受啊。求IKEv1下,客户端免导入证书的配置(主要是ipsec.conf和apple的mobileconfig)
weiyu99
2015-01-24 11:28:03 +08:00
@Caixiaopig 能把你成功的ipsec.con 关于 ikev2 这部份发给我参考一下吗?照著楼主教程过了 server 端认证就停了....
wzxjohn
2015-01-24 11:35:32 +08:00
@weiyu99 你有输出 Log 看看问题么?把日志贴出来看下吧。
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
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
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
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
leftid=@xxx.xxx.xxx
#your servr name in cert "server.pem"
rightid=client@xxx.xxx.xxx
#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[client@xxx.xxx]
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
2015-01-24 13:53:04 +08:00
@weiyu99 你的配置文件压根没写全,怎么可能能用。。。。。。。。。
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
leftid=@xxx.xxx.xxx
#your servr name in cert "server.pem"
rightid=client@xxx.xxx
#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
2015-03-11 17:00:44 +08:00
专业,mark
lavarong
2015-03-23 15:03:39 +08:00
@weiyu99 跟我的错误一样,你解决了吗?
lostff
2015-04-07 15:15:08 +08:00
发现这里是难得的国内讨论ios8/ikev2的地方,非常激动。
言归正传:
我现在搭建的环境ios只能用ikev1,因为我们需要同时用两种认证方式:
rightauth=pubkey
rightauth2=xauth-radius
也就是同时用证书和口令/用户,相应的在ios端安装的profile也会指定他们
ios8出来后尝试单独配置证书或者口令/用户,都可以连得通
但是一起用就不行,咨询过strongswan,答复是ios不支持
对于以上的困境,各位高人有何建议呢?
lostff
2015-04-08 10:07:07 +08:00
具体只用一种认证方式的配置是按官网上的例子配的
https://wiki.strongswan.org/projects/strongswan/wiki/AppleIKEv2Profile

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://tanronggui.xyz/t/137653

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX