HTML/JavaScript

2017年3月24日星期五

【Cisco】【安全】【CCNA】IKEv2建立(IKEv2 Packet Exchange)

IKEv2数据包交互(完成)

IKEv2建立(IKEv2 Packet Exchange)

介绍

IKEv1最初在RFC2409中进行定义,明确规定了IKEv1交互过程中分为Main Mode 和Aggressive Mode两种模式,在Main Mode中交互6个报文,在Aggressive Mode中交互3个报文。IKEv2与IKEv1不同,IKEv2最初在RFC 4306中进行定义,又在RFC5996中进行了修正。在IKEv2中没有Main Mode和Aggressive Mode说法。而是IKE_SA_INIT和IKE_AUTH 。在相同的环境下IKEv1完成建立需要交互9个报文,而IKEv2仅需要4个报文就能完成建立,相比于IKEv1,IKEv2更加紧凑和高效。
下图是IKEv2 Packet Exchange 交互过程,来自“IKEv2 IPsec Virtual Private Networks Understanding and Deploying”
Created with Raphaël 2.1.2InitiatorInitiatorResponderResponderIKE_SA_INIT( HDR, SAi1, KEi, Ni )IKE_SA_INIT( HDR, SAr1, KEr, Nr,[CertReq])↓Subsequent Encryption↓IKE_AUTH(HDR, SK {IDi, [Cert], [CertReq],)[AUTH], SAi2, TSi, TSr}IKE_AUTH(HDR, SK {IDr, [Cert], [AUTH], SAr2, TSi, TSr})
· HDR: IKE header
· SAi1: Sets of cryptographic algorithms proposed by initiator
· SAr1: Specific of cryptographic algorithms chosen by responder
· KEi: Initiator key exchange material (uses DH group with highest local priority)
· KEr: Responder key exchange material
· Ni : Initiator nonce
· Nr: Responder nonce
· CertReq: Certificate request (optional). The square brackets [ ] surrounding the CertReq payload denotes this as optional.
· SK { … } : Payload between { } is encrypted and integrity protected
· IDi : Initiator identity
· IDr : Responder identity
· Cert : Initiator certificate (optional)
· CertReq: Certificate request (optional)
· AUTH: Initiator and responder authentication data (not present if initiatorauthenticates via EAP)
· SAi2: Child SA transforms proposed by initiator
· SAr2: Child SA transforms chosen by responder
· TSi/TSr: Child SA traffic selectors (src/dst proxies)

IKE_SA_INIT Exchange

IKE_SA_INIT是ipsec vpn建立的初始交换,当完成IKE_SA_INIT交换之后后续其他的交互报文将被加密。下图是IKE_SA_INIT的数据包结构。
enter image description here
通过查看可以看到,在基础的IKE头部里面有多个payload,在payload又有多个Proposal组成,在Proposal中由多个Transform 组成。
纵观整个IKE_SA_INIT数据包可以发现。在IKE_SA_INIT数据包中包括的内容有。
· Security Association
 · Proposal
 · Transform(Encryption Algorithm、Pseudo-random Function、Integrity Algorithm、Diffie-Hellman Group)
· Key Exchang
· Nonce
通过观察可以看到,其实IKE_SA_INIT数据包中的内容就是IKEv1中主模式的1~4个报文。也就是说,IKE_SA_INIT对IKEv1中1~4个报文进行了整合,使得交互更加高效。通过IKE_SA_INIT传递“材料”就可以完成后续报文的加密工作,当IKE_SA_INIT交互完成之后后续其他交互的报文将被加密。

IKE_AUTH Exchange

一旦IKE_SA_INIT交换成功完成,IKE_AUTH交换将会开始,用于认证对方,并产生IPsec Security Associations。下图是IKE_AUTH的报文。因为关键的信息被加密,我们无法获知其中的内容,不过笔者通过查阅IKEv2 IPsec Virtual Private Networks Understanding and Deploying 和RFC5996发现这一部分还是可以说清楚的。
Internet Security Association and Key Management Protocol
Initiator SPI: 82752e51d889cf91
Responder SPI: 7f79f53a9737fe8f
Next payload: Encrypted and Authenticated (46)
Version: 2.0
    0010 .... = MjVer: 0x2
    .... 0000 = MnVer: 0x0
Exchange type: IKE_AUTH (35)
Flags: 0x08 (Initiator, No higher version, Request)
    .... 1... = Initiator: Initiator
    ...0 .... = Version: No higher version
    ..0. .... = Response: Request
Message ID: 0x00000001
Length: 352
Type Payload: Encrypted and Authenticated (46)
    Next payload: Vendor ID (43)
    0... .... = Critical Bit: Not Critical
    Payload length: 324
    Initialization Vector: e8d40dfc
    Encrypted Data
在IKEv2中先通过messages#1 和messages#2创建IKE SA 进行加密,然后通过messages#3和messages#4消息进行认证,认证完成之后将建立 CHILD_SA。其中IKE_AUTH所带的信息如下。
IKE头部(明文)、加密部分:发起者身份(IDi)、发起者证书(Cert)、证书请求(CertReq)、发起方和应答者身份验证数据(AUTH)、响应者选择的Child SA转换(SAr2)、Child SA流量选择器。
在IKEv2中支持签名认证、预共享密钥、EAP进行身份验证,采用什么样的方式进行认证就携带响应的信息。
通过Cisco debug信息发现在IKE_AUTH中主要交换如下几个Payload。
*Mar 21 01:21:39.829: IKEv2:Construct Vendor Specific Payload: CISCO-GRANITE
*Mar 21 01:21:39.833: IKEv2:Construct Notify Payload: INITIAL_CONTACT
*Mar 21 01:21:39.833: IKEv2:Construct Notify Payload: SET_WINDOW_SIZE
*Mar 21 01:21:39.837: IKEv2:Construct Notify Payload: ESP_TFC_NO_SUPPORT
*Mar 21 01:21:39.841: IKEv2:Construct Notify Payload: NON_FIRST_FRAGS
其中INITIAL_CONTACT Payload是用于标识对等体之间唯一的唯一的IKEv2会话以前任何会话现在都无效,应该被删除。当主机在IKE_AUTH交换机内发送INITIAL_CONTACT通知时执行初始联系,在认证成功之后需要检查和此对等体还有没有其他的IKEv2会话,如果有则删除,如果没有那么就断言最新的IKEv2 SA是双方当前唯一的IKEv2 SA。
IKEv2中认证是一个大项,有很多东西不在此文档中展开,在此不再展开赘述,有兴趣的可以查阅“IKEv2 IPsec Virtual Private Networks Understanding and Deploying”当中有详细的介绍。

IKE SA states

enter image description here
因为在看debug信息的时候才会关注IKEv2中的状态,所以在此稍微说一下。
发起者INIT状态表示IKE_SA_INIT请求尚未发送。
应答方的INIT状态表示响应者正在处理从发起者接收到的IKE_SA_INIT请求。
WAIT KE状态指示发起者已经发送了IKE_SA_INIT请求,并且正在等待来自响应者的IKE_SA_INIT响应。
WAIT KE状态指示应答方已经处理了IKE_SA_INIT并正在等待来自发起者的IKE_AUTH请求。
发起方的WAIT AUTH状态表示发起方发送了IKE_AUTH请求
应答方的WAIT AUTH状态表示响应方已收到IKE_AUTH请求
发起方的DONE状态表示启动器已经收到IKE_AUTH响应
应答方的DONE状态表示响应者已经发送了IKE_AUTH响应

参考文献

  1. IKEv2 Packet Exchange and Protocol Level Debugging
  2. RFC 5996
  3. IKEv2 Phase 1 (IKE SA) and Phase 2 (Child SA) Message Exchanges
  4. IOS IKEv2 Debugs for Site-to-Site VPN with PSKs Troubleshooting TechNote
  5. Interpreting IKEv2 IKE SA states
  6. IKEv2 IPsec Virtual Private Networks Understanding and Deploying
    (因为版权问题,这个书没有办法直接上传分享出来,如果有兴趣查看的可以联系我 ccie43413@yahoo.com)

2017年3月21日星期二

文档记录

收集的信息,已经全部转存到google drive  上。可以查看或下载。(2017年10月17日17:32:33)

https://drive.google.com/drive/folders/0B93yYDHcYIgCNm9oRE16SC1vUjQ?usp=sharing

Ethernet Frame Calculations
http://www.erg.abdn.ac.uk/Users/gorry/course/lan-pages/enet-calc.html

Carrier Sense Multiple Access with Collision Detection (CSMA/CD)
http://www.erg.abdn.ac.uk/Users/gorry/course/lan-pages/csma-cd.html

The Internet Key Exchange (IKE)
https://tools.ietf.org/html/rfc2409

IOS IPSec and IKE debugs - IKEv1 Main Mode Troubleshooting
http://www.cisco.com/c/en/us/support/docs/security-vpn/ipsec-negotiation-ike-protocols/113594-trouble-ios-ike-00.html#anc11

IKE main mode, aggressive mode, & phase 2.
https://ccie-or-null.net/2012/03/26/ike-main-mode-aggressive-mode-phase-2/

IKE and ISAKMP
http://flylib.com/books/en/2.45.1.26/1/

IPSec Overhead Calculator Tool
https://cway.cisco.com/tools/ipsec-overhead-calc/

IPSec Encapsulating Security Payload (ESP)
www.tcpipguide.com/free/t_IPSecEncapsulatingSecurityPayloadESP-4.htm

How to Calculate TCP throughput for long distance WAN links
http://bradhedlund.com/2008/12/19/how-to-calculate-tcp-throughput-for-long-distance-links/

Framework for TCP Throughput Testing
https://tools.ietf.org/html/rfc6349

INACON Protocol Help
http://www.inacon.de/ph/data/index.php

IKEv2 Packet Exchange and Protocol Level Debugging
http://www.cisco.com/c/en/us/support/docs/security-vpn/ipsec-negotiation-ike-protocols/115936-understanding-ikev2-packet-exch-debug.html 

IPSec Virtual Tunnel Interface
http://www.cisco.com/en/US/docs/ios/12_3t/12_3t14/feature/guide/gtIPSctm.html#wp1085879

Implementing Group Domain of Interpretation in a Dynamic Multipoint VPN
http://www.cisco.com/c/en/us/products/collateral/ios-nx-os-software/getvpn-solution-managed-services/prod_white_paper0900aecd804c363f.html


IKEv2 between IOS routers (SVTI – Static Virtual Tunnel Interface)
https://popravak.wordpress.com/2015/01/31/ikev2-between-ios-routers-svti-static-virtual-tunnel-interface/


Configuring a Router IPsec Tunnel Private-to-Private Network with NAT and a Static(NAT配置,重点看)
http://www.cisco.com/c/en/us/support/docs/security-vpn/ipsec-negotiation-ike-protocols/14144-static.html


NAT Order of Operation(出、入操作顺序)
http://www.cisco.com/c/en/us/support/docs/ip/network-address-translation-nat/6209-5.html

IOS Router to Pass a LAN-to-LAN IPSec Tunnel via PAT Configuration Example
http://www.cisco.com/c/en/us/support/docs/security-vpn/ipsec-negotiation-ike-protocols/23820-ios-pat-ipsec-tunnel.html

IPsec NAT Transparency
http://www.cisco.com/en/US/docs/ios-xml/ios/sec_conn_dplane/configuration/15-2mt/sec-ipsec-nat-transp.html

china-ccie【NAT Traversal(NAT-T)】
http://www.china-ccie.com/doc/vpn/vpn.html#49

CISCO路由器NAT-T与IPSec VPN配置实验【实践闯未来】
http://fjxsunmit.blog.51cto.com/326634/140001

技术点详解---IPSec穿越NAT
http://www.h3c.com.cn/MiniSite/Technology_Circle/Technology_Column/ICG/ICG_Technology/201006/677319_97665_0.htm

TCP Checksum Calculation and the TCP "Pseudo Header"
http://www.tcpipguide.com/free/t_TCPChecksumCalculationandtheTCPPseudoHeader-2.htm

IP NAT Compatibility Issues and Special Handling Requirements
http://www.tcpipguide.com/free/t_IPNATCompatibilityIssuesandSpecialHandlingRequirem.htm

Configuring IKEv2 Load Balancer
http://www.cisco.com/en/US/docs/ios-xml/ios/sec_conn_ike2vpn/configuration/15-2mt/sec-cfg-clb-supp.html#GUID-A2F15B1D-271F-4AA9-BE75-45BB79B8F812

IPsec High Availability (stateful)
https://myitmicroblog.svbtle.com/ipsec-high-availability-stateful

Reverse Route Injection
http://www.cisco.com/en/US/docs/ios-xml/ios/sec_conn_vpnav/configuration/15-2mt/sec-rev-rte-inject.html

VPN Availability Configuration Guide, Cisco IOS Release 15M&T
http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/sec_conn_vpnav/configuration/15-mt/sec-vpn-availability-15-mt-book/sec-state-fail-ipsec.html

Stateful Switchover(SSO)
http://www.cisco.com/c/en/us/td/docs/ios/12_0s/feature/guide/sso120s.html

配置Stateful Failover for IPsec(china-ccie)
http://www.china-ccie.com/doc/vpn/vpn.html#49

Bandwidth, Packets Per Second, and Other Network Performance Metrics
http://www.cisco.com/c/en/us/about/security-center/network-performance-metrics.html

How can I calculate the switching forwarding rate and packet forwarding rate of ports?
https://kb.zyxel.com/KB/searchArticle!gwsViewDetail.action?articleOid=007011&lang=EN

IKEv2 Load Balancer #1
IKEv2 Load Balancer #2
https://router898.wordpress.com/2016/08/02/ikev2-load-balancer-1/
https://router898.wordpress.com/2016/08/30/ikev2-load-balancer-2/


DMVPN Phase 3
http://blog.ine.com/2008/12/23/dmvpn-phase-3/

NHRP-cisco
http://www.cisco.com/c/en/us/td/docs/ios/12_4/ip_addr/configuration/guide/hadnhrp.html

光纤组件(fiber-optic-components)
http://www.fiber-optic-components.com/category/optical-transceiver/sfp

DMVPN PHASE III – PART 1
DMVPN PHASE III – PART 2
https://abhishektechdecoder.wordpress.com/2016/12/07/dmvpn-phase-iii-part-1/
https://abhishektechdecoder.wordpress.com/2016/12/09/dmvpn-phase-iii-part-2/

iTest Lite 4.0
http://itest-lite.software.informer.com/4.0/


Cisco Site-to-Site VPN Technologies Comparison
https://www.cisco.com/c/dam/en/us/products/collateral/ios-nx-os-software/enterprise-class-teleworker-ect-solution/prod_brochure0900aecd80582078.pdf

Chapter: Cisco Group Encrypted Transport VPN
https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/sec_conn_getvpn/configuration/xe-3s/sec-get-vpn-xe-3s-book/sec-get-vpn.html

Group Encrypted Transport VPN (Get VPN) Design and Implementation Guide
https://www.cisco.com/c/dam/en/us/products/collateral/security/group-encrypted-transport-vpn/GETVPN_DIG_version_1_0_External.pdf


Chapter 17. Group Encrypted Transport VPN (GET VPN)【重点看】
https://lira.epac.to/DOCS-TECH/Security/Internet%20Security%20Technology%20and%20Hacking/final/ch17lev1sec1.html

SNMP读取设备信息软件
https://syslogwatcher.com/cmd-tools/snmp-walk/

ASA 8.X: Routing SSL VPN Traffic through Tunneled Default Gateway Configuration Example
https://www.cisco.com/c/en/us/support/docs/security/asa-5500-x-series-next-generation-firewalls/112182-ssl-tdg-config-example-00.html

Enterprise Data Communication Products Feature Description - VPN
http://support.huawei.com/enterprise/documentOnline?contentId=DOC1000009655&sendFrom=mobile&currentPartNo=10012&togo=content

TLS/SSL - page 2
https://blog.cryptographyengineering.com/category/tlsssl/page/2/

Secure Socket Layer
http://techgenix.com/secure_socket_layer/

SSL: Foundation for Web Security - The Internet Protocol Journal - Volume 1, No. 1
https://www.cisco.com/c/en/us/about/press/internet-protocol-journal/back-issues/table-contents-18/ssl.html

Keyless SSL: The Nitty Gritty Technical Details
https://blog.cloudflare.com/keyless-ssl-the-nitty-gritty-technical-details/#ephemeraldiffiehellmanhandshake

浅析数字证书
http://www.cnblogs.com/hyddd/archive/2009/01/07/1371292.html

Ssl handshake with two way authentication with certificates.svg
https://upload.wikimedia.org/wikipedia/commons/4/42/Ssl_handshake_with_two_way_authentication_with_certificates.svg

IPv6 mtu为什么是1280
https://www.ietf.org/mail-archive/web/ipv6/current/msg14572.html

tcpdump使用技巧 and vim
http://linuxwiki.github.io/NetTools/tcpdump.html
http://linuxwiki.github.io/ProductivityTools/vim.html

Fragmentation in IPv4 and IPv6
The basics about MTU, MSS, GRE, and PMTU
https://skminhaj.wordpress.com/2016/02/15/fragmentation-in-ipv4-and-ipv6/
https://skminhaj.wordpress.com/2016/02/15/the-basics-about-mtu-mss-gre-and-pmtu/

网络基础之以太网帧,MTU,MSS
https://www.mnstory.net/2017/07/05/network-ethernet-mtu-mss/

Ethernet Frame Calculations
http://www.erg.abdn.ac.uk/users/gorry/course/lan-pages/enet-calc.html

Spirent TestCenter: 突发流量
https://support.spirent.com/SpirentCSC/SC_KnowledgeView?Id=SOL12760

SampleCaptures - The Wireshark Wiki.mht
https://wiki.wireshark.org/SampleCaptures

IP Packet Overhead
http://www.tamos.net/~rhay/overhead/ip-packet-overhead.htm


图片
—————————————————————————————————————



2017年3月10日星期五

【Cisco】【安全】【CCNA】IKEv2简单介绍(RFC5996)

IKEv2简单介绍

大多数内容来自于RFC 5996,仅供参考,如有错误请指正,谢谢。

IKE Header

                        1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                       IKE SA Initiator's SPI                  |
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                       IKE SA Responder's SPI                  |
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Next Payload | MjVer | MnVer | Exchange Type |     Flags     |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                          Message ID                           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                            Length                             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • IKE SA Initiator’s SPI:由发起者配置的值标识唯一的IKE安全关联,此值不能 为零。
  • IKE SA Responder’s SPI:响应者选择的值标识唯一的IKE安全关联。在首次进行交换的过程中此值为0。
  • Next Payload:指示有效载荷的类型每个的格式和值 有效载荷定义如下。
      Next Payload Type                Notation  Value
      ---------------------------------------------
      No Next Payload                             0
      Security Association             SA         33
      Key Exchange                     KE         34
      Identification - Initiator       IDi        35
      Identification - Responder       IDr        36
      Certificate                      CERT       37
      Certificate Request              CERTREQ    38
      Authentication                   AUTH       39
      Nonce                            Ni, Nr     40
      Notify                           N          41
      Delete                           D          42
      Vendor ID                        V          43
      Traffic Selector - Initiator     TSi        44
      Traffic Selector - Responder     TSr        45
      Encrypted and Authenticated      SK         46
      Configuration                    CP         47
      Extensible Authentication        EAP        48
  • Major Version:显示IKE的主要版本。
  • Minor Version:显示ike的次要版本。
  • Exchange Type:显示交换报文的类型
      Exchange Type             Value
      ----------------------------------
      IKE_SA_INIT               34
      IKE_AUTH                  35
      CREATE_CHILD_SA           36
      INFORMATIONAL             37
  • Flags:表示特定选项信息。
        +-+-+-+-+-+-+-+-+
        |X|X|R|V|I|X|X|X|
        +-+-+-+-+-+-+-+-+
  • R bit:表示是一个响应者。
  • V bit:发起方能够提供一个更高的IKE版本,在IKEv2中发送者此位不置位,接受者忽略此位。
  • I bit:表示是一个发起者。
    • Message ID:用于实现IKEv2中请求、响应、重传操作。
    • Length:消息总长度(header + payloads)。

Generic Payload Header

                     1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | Next Payload  |C|  RESERVED   |         Payload Length        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Next Payload:消息中下一个有效载荷的有效载荷类型的标识符,如果当前有效载荷是消息中的最后一个,则该字段将为0.该字段提供“链接”能力,从而可以通过将每个附加到消息的末尾并将“下一个”有效载荷“字段以指示新有效载荷的类型。(类似于IPv6中的Next header)
      Next Payload Type                Notation  Value
      --------------------------------------------------
      No Next Payload                             0
      Security Association             SA         33
      Key Exchange                     KE         34
      Identification - Initiator       IDi        35
      Identification - Responder       IDr        36
      Certificate                      CERT       37
      Certificate Request              CERTREQ    38
      Authentication                   AUTH       39
      Nonce                            Ni, Nr     40
      Notify                           N          41
      Delete                           D          42
      Vendor ID                        V          43
      Traffic Selector - Initiator     TSi        44
      Traffic Selector - Responder     TSr        45
      Encrypted and Authenticated      SK         46
      Configuration                    CP         47
      Extensible Authentication        EAP        48
  • Critical:如果发送方希望接收方在不理解(not understand)有效载荷类型时拒绝整个消息,则必须设置为1。
  • RESERVED:保留位。
  • Payload Length:current payload + generic payload header

Security Association Payload

Security Association payload中可以包括多个proposals,必须按照优选到最不优选的方式进行排序,一个Security Association有一个或多个Proposal 组成。每一个Proposal 包括一个或多个Transform ,在每一个Transform 下面包括需要指定的加密属性。

                     1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | Next Payload  |C|  RESERVED   |         Payload Length        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                                                               |
   ~                          <Proposals>                          ~
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Payload内容与之前一致,不再赘述。

例如当有多个Proposal的时候表格如下

   SA Payload
      |
      +--- Proposal #1 ( Proto ID = ESP(3), SPI size = 4,
      |     |            7 transforms,      SPI = 0x052357bb )
      |     |
      |     +-- Transform ENCR ( Name = ENCR_AES_CBC )
      |     |     +-- Attribute ( Key Length = 128 )
      |     |
      |     +-- Transform ENCR ( Name = ENCR_AES_CBC )
      |     |     +-- Attribute ( Key Length = 192 )
      |     |
      |     +-- Transform ENCR ( Name = ENCR_AES_CBC )
      |     |     +-- Attribute ( Key Length = 256 )
      |     |
      |     +-- Transform INTEG ( Name = AUTH_HMAC_SHA1_96 )
      |     +-- Transform INTEG ( Name = AUTH_AES_XCBC_96 )
      |     +-- Transform ESN ( Name = ESNs )
      |     +-- Transform ESN ( Name = No ESNs )
      |
      +--- Proposal #2 ( Proto ID = ESP(3), SPI size = 4,
            |            4 transforms,      SPI = 0x35a1d6f2 )
            |
            +-- Transform ENCR ( Name = AES-GCM with a 8 octet ICV )
            |     +-- Attribute ( Key Length = 128 )
            |
            +-- Transform ENCR ( Name = AES-GCM with a 8 octet ICV )
            |     +-- Attribute ( Key Length = 256 )
            |
            +-- Transform ESN ( Name = ESNs )
            +-- Transform ESN ( Name = No ESNs )

IKEv2特性

请求和响应(Request and Response)

IKE中的所有消息都是成对的存在,分为请求响应,并且对于安全关联来说,一端是发起者,一端是响应者。对于每个IKE消息,发起者负责在超时的情况下重传,响应者不允许重传响应消息。除非响应者接收到了重传的请求。发起者必须记录每个请求,直到收到了相应的响应信息。响应者必须记录每个响应直到它接收到正确的序列号的请求。为了节省内存,响应者允许设置超时时间,在超时时间之外收到了请求那么必须忽略请求,而不是尝试重新建立。IKE是一种可靠的协议,发起者必须重传请求,直到请求被确认,如果响应者认为IKE SA失败,这种情况下,
应当重置所有的状态与IKE SA协商的 子SA相关联。

Message ID

每个 IKE消息包含 Message ID,作为固定报头中的一部分。Message ID消息用于匹配请求响应,重传的消息必须使用与原始消息相同的 Message ID,Message ID是 32 bit数,每进行一次消息传递的时候Message ID 加 1,当Message ID消息太大以至于不能容纳32 bit的时候 IKE SA必须关闭或重新申请密钥,如果重置IKE SA那么Message ID将置0。Message ID受加密保护,可以防止重放攻击。

重复请求窗口大小(Window Size for Overlapping Requests)

SET_WINDOW_SIZE通知允许接受者在获得第一个响应之前发送多个请求。在IKE SA建立之后,为了最大化IKE吞吐量,IKE端点可以在获得任何响应之前发出多个请求,直到达到由其对等体的SET_WINDOW_SIZE设置的限制。 可以接受和处理多个请求。IKE端点不得超过对等体对于所发送的IKE请求的所述窗口大小。IKE端点必须保持等于其声明的窗口大小的先前响应的消息(已确保这些消息丢弃的时候可以被重传),以防其响应报文丢失。新的IKE SA以窗口大小1开始,直到通过发送新的SET_WINDOW_SIZE通知来显式增加。当接收到支持的窗口之外的IKE消息ID时,发送INVALID_MESSAGE_ID通知。此通知消息不得在响应中发送。

状态同步和连接超时

一个IKE端点允许删除所有与之相关的IKE SA,并随时与相应的子SA关联其状态。这是在端点本框和重启情况下的预期行为,保证了当端点发生故障的时候重新初始化其状态,以保证接受到不必要的流量丢入到黑洞中,而不必浪费网络的带宽。INITIAL_CONTACT通知是在认证身份之间当前活动的唯一IKE SA。它可以在崩溃后建立IKE SA时发送,并且接受者可以使用此信息删除其具有的相同的IKE SA,而无需等待超时。INITIAL_CONTACT通知,如果发送,必须在第一个IKE_AUTH请求或响应,接收方可以在其他消息中忽略它。

IKE SA SPIs and Cookies

头部中的最初两个八字节字段(称为“IKE SPI”“Initiator SPI、Responder SPI”)用作IKE分组开始处的连接标识符。 IKE SPI是IKE SA的唯一标识符。 SPI值为零是特殊的:它表示Remote SPI值尚未被发送方知道。传入进来的数据包通过SPI值去匹配到相应的IKE SA。在初始IKE交换的第一个消息中,发起方不知道响应方的SPI值,因此将该字段设置为零。 如果响应者发送非零响应者SPI(non-zero responder SPI),则发起者不应以此原因拒绝响应。

IKE_SA_INIT是对等体建立安全信道的初始交换。在完成初始交换之后,所有进一步的交换被加密。交换仅包含两个分组这样会消耗比较多的硬件资源,正是因为这样的缺点容易遭受DOS攻击。为了防止这种攻击,IKEv2在IKE_SA_INIT中有一个可选交换,如果到达攻击阈值,响应者不继续处理这些交换分组,而是使用cookie发给发送者,如果需要建立会话,那么发送者必须重新发送IKE_SA_INIT数据包,并附上收到了cookie。一个好的方法是将响应者cookie设置为:

Cookie = <VersionIDofSecret> | Hash(Ni | IPi | SPIi | <secret>)

其中<secret>是随机生成的密钥,仅对应答者知道并且周期性地改变。
<VersionIDofSecret>应在每次重新生成<secret>时更改。

如下就是 Here is a diagram of IKE_SA_INIT exchange with cookie challenge:

   Initiator                         Responder
   -----------------------------------------------------------
   HDR(A,0), SAi1, KEi, Ni  -->
                                <--  HDR(A,0), N(COOKIE)
   HDR(A,0), N(COOKIE), SAi1,
       KEi, Ni  -->
                                <--  HDR(A,B), SAr1, KEr,
                                         Nr, [CERTREQ]
   HDR(A,B), SK {IDi, [CERT,]
       [CERTREQ,] [IDr,] AUTH,
       SAi2, TSi, TSr}  -->
                                <--  HDR(A,B), SK {IDr, [CERT,]
                                         AUTH, SAr2, TSi, TSr}
   Notation    Payload
   -----------------------------------------
   AUTH        Authentication(认证)
   CERT        Certificate(证书)
   CERTREQ     Certificate Request(请求证书)
   CP          Configuration
   D           Delete
   EAP         Extensible Authentication
   HDR         IKE header (not a payload)
   IDi         Identification - Initiator(识别 - 发送者)
   IDr         Identification - Responder(识别 - 响应者)
   KE          Key Exchange
   Ni, Nr      Nonce(随机数)
   N           Notify(通知)
   SA          Security Association
   SK          Encrypted and Authenticated
   TSi         Traffic Selector - Initiator流量选择器 - 发送者
   TSr         Traffic Selector - Responder流量选择器 - 响应者
   V           Vendor ID

   HDR包含安全参数索引(SPI),版本号和各种标志。

   SAi1有效载荷指示发起方为IKE SA支持的加密算法

   KE有效载荷发送发起者的Diffie-Hellman值。

   Ni是启动器的随机数。

   The responder chooses a cryptographic suite from the initiator's
   offered choices and expresses that choice in the SAr1 payload,
   completes the Diffie-Hellman exchange with the KEr payload, and sends
   its nonce in the Nr payload.

加密算法协商

一个Security Association有一个或多个Proposal 组成。每一个Proposal 包括一个或多个Transform ,在每一个Transform 下面包括需要指定的加密属性。响应者依据自己的需求选择对应的Proposal 。如果拒绝那么错误在类型NO_PROPOSAL_CHOSEN的通知中给出。

密钥

IKE,ESP和AH的安全关联仅在有限的时间内使用,并保护相关数据,当安全关联到期的时候不得再继续使用此安全关联,如果有继续保护数据的需求,需要重新建立安全关联。重新建立的安全关联将取代过期的安全关联,称之为“密钥更新”。
为了实现ipsec 的密钥更新平滑过渡,需要在不重启整个IKE SA的情况下实现密钥更新,如果在密钥更新期间发生失败,那么必须关闭现有的子SA,然后重新开始新的的SA,当新的SA建立完成之后就删除旧的SA。旧的SA不能再继续使用。在旧的SA即将删除之前,必须先建立新的SA,在此之间必须预留足够多的时间,使得新的SA得以建立,以保证业务流量可以切换到新的SA上。

当需要密钥更新的时候,使用现有的CREATE_CHILD_SA,与对端建立新的等效IKE SA(equivalent IKE SA),这样创建的IKE SA会继承所有原始IKE SA 的子SA控制信息。当创建新的IKE SA之后,发起方删除旧的IKE SA ,同时也会向对端发送一个请求,对端收到这个请求之后也会删除旧的IKE SA。
IKEv1与IKEv2区别在于IKEv1 SA生存周期协商,但是在IKEv2中SA是每端自行维护,如果两端生存周期不一致,那么较短的生存周期的将先生成新的密钥,如果SA长期不活动,也不存在流量的情况下,可以选择关闭SA,而不是等待SA寿命超时。

需要注意的是:如果两端配置相同的生存期策略,则可能两者将同时发起重新生成密钥(这将导致冗余SA)。 为了减少发生这种情况的可能性,请求密钥请求的定时应当抖动(在注意到需要重新密钥化之后延迟随机时间量)。

参考文献

1.IKEv2 Packet Exchange and Protocol Level Debugging
2.RFC5996

2017年3月6日星期一

【Cisco】【安全】【CCNA】IKEv2配置说明

IKEv2配置说明

IKEv2命令说明

IKEv2 Proposal

IKEv2 proposal是IKE SA中协商转换集(Transforms Collection)在IKE_SA_INIT交换中的一部分。在协商过程中转换类型如下:

  • Encryption algorithm
  • Integrity algorithm
  • Pseudo-Random Function (PRF) algorithm
  • Diffie-Hellman (DH) group
R1(config)#crypto ikev2 proposal ikev2-proposal 
R1(config-ikev2-proposal)#?
IKEv2 Proposal commands:
  encryption  Set encryption algorithm(s) for proposal
  exit        Exit from IKEv2 proposal configuration mode
  group       Set the Diffie-Hellman group(s)
  integrity   Set integrity hash algorithm(s) for proposal
  no          Negate a command or set its defaults

IKEv2 policy

IKEv2 policy包含用于在SA_INIT交换中协商 加密,完整性,PRF算法和DH组。

R1(config)#crypto ikev2 policy ikev2-policy 
R1(config-ikev2-policy)#?
IKEv2 Policy commands:
  exit      Exit from IKEv2 policy configuration mode
  match     Match values of local fields
  no        Negate a command or set its defaults
  proposal  Specify Proposal

IKEv2 Keyring

IKEv2 Keyring是对称和非对称预共享密钥的存储库。

R1(config)#crypto ikev2 keyring ikev2-keyring
R1(config-ikev2-keyring)#?
IKEv2 Keyring commands:
  exit  Exit from crypto ikev2 keyring sub mode
  no    Negate a command or set its defaults
  peer  Configure a Peer and associated keys

IKEv2 Profile

IKEv2 profile是IKE SA的不可协商(NonNegotiable)参数的存储库,如本地或远程身份和身份验证方法和可用相匹配的配置文件,经过身份验证的对等体提供的服务。

R1(config)#crypto ikev2 profile ikev2-profile
R1(config-ikev2-profile)#?
IKEv2 profile commands:
  aaa               Specify AAA related configs
  authentication    Set authentication method
  config-exchange   config-exchange options
  description       Specify a description of this profile
  dpd               Enable IKE liveness check for peers
  exit              Exit from crypto ikev2 profile sub mode
  identity          Specify IKE identity to use
  initial-contact   initial-contact processing
  ivrf              I-VRF of the profile
  keyring           Specify keyring to use
  lifetime          Set lifetime for ISAKMP security association
  match             Match values of peer
  nat               NAT-transparency
  no                Negate a command or set its defaults
  pki               Specify certificate authorities to trust
  redirect          IKEv2 Redirect Mechanism for load-balancing
  virtual-template  Specify the virtual-template for dynamic interface

IPsec Transform-set

crypto ipsec transform-set是定义变换集(To define a transform set),定义适合的安全协议和加密算法。

R1(config)#crypto ipsec transform-set ikev2-transform-set esp-aes esp-sha-hmac
Crypto transform configuration commands:
  default  Set a command to its defaults
  exit     Exit from crypto transform configuration mode
  mode     encapsulation mode (transport/tunnel)
  no       Negate a command or set its defaults

crypto map

crypto 集合,集合内容如下。

  • set peer      关联IPsec对等体
  • set transform-set  关联转换集
  • set ikev2-profile  关联SA_INIT交换中协商参数
  • match address  定义感兴趣数据流
R2(config)#crypto map ikev2-map 10 ipsec-isakmp
Crypto Map configuration commands:
  default        Set a command to its defaults
  description    Description of the crypto map statement policy
  dialer         Dialer related commands
  exit           Exit from crypto map configuration mode
  match          Match values.
  no             Negate a command or set its defaults
  qos            Quality of Service related commands
  reverse-route  Reverse Route Injection.
  set            Set values for encryption/decryption

配置步骤

  1. 通过ikev2 proposal定义 Encryption,Hash Algorithm,Diffie-Hellman group,这一步类似于IKEv1中的“crypto isakmp policy”。
  2. 通过policy去调用proposal,这样做的好处是,当需要配置多个VPN的时候,不需要每一个VPN去配置Encryption,Hash Algorithm,Diffie-Hellman group这些信息,直接调用之前配置好的proposal即可。
  3. 配置keying,在keying中配置对等体的IP地址,并且配置预共享密钥。
  4. 配置profile配置集合,确定认证方式和调用秘钥
  5. 配置transform-set指定ipsec vpn模式,传输模式or隧道模式。
  6. 配置感兴趣的数据流,通过ACL。
  7. 配置crypto map集合,并在接口下应用。

因为配置命令比较麻烦,我经常使用PPKP(proposal->policy->keyring->profile)来简化配置思路。

配置示例

crypto ikev2 proposal ikev2-proposal
 encryption1 aes-cbc-256
 integrity2 sha512
 group3 16
!
crypto ikev2 policy ikev2-policy 
 match fvrf4 any
 proposal5 ikev2-proposal
!
crypto ikev2 keyring ikev2-keyring
 peer6 ccie43413
  address7 12.1.1.1
  pre-shared-key8 local ccie43413
  pre-shared-key9 remote ccie43413
 !
!
crypto ikev2 profile ikev2-profile
 match identity remote address 12.1.1.1 255.255.255.255 10
 authentication remote pre-share11
 authentication local pre-share 12
 keyring local ikev2-keyring13
!
crypto ipsec transform-set ikev2-transform-set esp-aes esp-sha-hmac 
 mode tunnel
!
crypto map ikev2-map 10 ipsec-isakmp 
 set peer 12.1.1.1
 set transform-set ikev2-transform-set 
 set ikev2-profile ikev2-profile
 match address vpn
!
ip access-list extended vpn
 permit ip host 10.1.1.1 host 20.1.1.1
!

参考文献

1.Configuring Internet Key Exchange Version 2 (IKEv2)

2.IKEv1/IKEv2 Between Cisco IOS and strongSwan Configuration Example

3.IPSec Network Security Commands

脚注


  1. Specifies one or more transforms of the encryption type.
  2. Specifies one or more transforms of the integrity algorithm type
  3. Specifies the Diffie-Hellman (DH) group identifier.A generally acccepted guideline recommends the use of a 2048-bit group after 2013 (until 2030). Either group 14 or group 24 can be selected to meet this guideline
  4. (Optional) Matches the policy based on a user-configured FVRF or any FVRF.这部分详细,请参阅Configuring VPNs in VRF Mode
  5. Specifies the proposals that must be used with the policy.
  6. Defines the peer or peer group and enters IKEv2 keyring peer configuration mode.
  7. Specifies an IPv4 or IPv6 address or range for the peer.
  8. Specifies the preshared key for the peer
  9. Specifies the preshared key for the peer
  10. Use the match statements to select an IKEv2 profile for a peer:
  11. Specifies the local or remote authentication method.
  12. Specifies the local or remote authentication method.
  13. Specifies the local or AAA-based keyring that must be used with the local and remote preshared key authentication method

2017年3月2日星期四

【Cisco】【安全】【CCNA】IKEv1与IKEv2对比

IKEv1 vs IKEv2 (2)

IKEv1和IKEv2对比

表格来自于

Table IKEv1 IKEv2 注释
SA IPsec SA Child SA RFC60711
Exchange modes Main mode: 9 messages
Aggressive mode: 6 messages
最少 4 messages. RFC24092
认证模式 Pre-Shared Key (PSK)3
Digital Signature (RSA-Sig)4
Public Key Encryption5
Revised Mode of Public key Encryption6
Pre-Shared Key (PSK)7
Digital Signature (RSA-Sig)8
RFC2049
RFC6738
身份验证方法 两端认证必须配置相同 两端认证配置可以不同 RFC60719
流量选择器
(Traffic selector)
每个IPsec SA仅允许源IP范围,目标IP范围,
源端口和目标端口的组合。需要在对等体之间精确地匹配流量选择器。
多个组合,每个子SA允许源IP范围,目标IP范围,源端口范围和目标端口范围。 RFC599610
SA老化 需要对等体支持 没有协商,每个对等体可以通过交换DELETE有效载荷随时删除SA。 RFC599611
多主机 不支持 通过在单个IP地址和端口对上使用多个ID来支持 RFC455512
密钥 没有定义 定义 RFC599613
NAT穿越 需要在扩展中进行支持 默认即支持 RFC599614
远程接入VPN 不支持,需要特定厂商进行支持例如Cisco的Extended Authentication (XAUTH) 默认支持:
Extensible Authentication Protocol (EAP)
通过EAP的用户认证与IKE的认证进行关联配置Configuration payload (CP)
RFC510615
DoS防护 不支持 支持Anti-replay,'Cookies'支持缓解洪泛攻击(flooding attacks),修复IKEv1漏洞 RFC631116
传输可靠性 相对可靠性低 消息以请求-回复的方式交互
定义了删除SA的操作
定义了消息重传
RFC4306 17
扩展性 扩展性弱 IKEv2的重定向机制(RFC5685)
IKEv2会话恢复(RFC5723)
协议支持IKEv2 / IPsec的高可用性(RFC6311)
IKEv2中的仅EAP认证的扩展(RFC5998)
一个快速故障检测方法Internet密钥交换协议(IKE)(RFC6290)
-

参考文献


  1. RFC6071: It is called the IPsec SA in IKEv1 and, in the IKEv2 RFCs, it is referred to variously as a CHILD_SA, a child SA, and an IPsec SA. This document uses the term "IPsec SA". To further complicate the terminology, since IKEv1 consists of two sequential negotiations, called phases, the IKE SA is also referred to as a Phase 1 SA and the IPsec SA is referred to as a Phase 2 SA. 

  2. RFC2409: 7 Payload Explosion of Complete Exchange 

  3. RFC2409: 5.4 Authentication with a Pre-Shared Key 

  4. RFC2409: 5.1 Authentication with Digital Signatures 

  5. RFC2409: 5.2 Authentication with Public Key Encryption 

  6. RFC2409: 5.3 A Revised method of Authentication with Public Key Encryption 

  7. RFC6738 

  8. RFC7427 

  9. RFC6071: 2.3.1 Differences between IKEv1 and IKEv2 

  10. RFC5996: 2.9. Traffic Selector Negotiation 

  11. RFC5996: 2.8. Rekeying 

  12. RFC4555 

  13. RFC5996: 2.8. Rekeying 

  14. RFC5996: 2.23. NAT Traversal 

  15. RFC5106:  

  16. RFC6311: 4. The IKEv2/IPsec SA Counter Synchronization Problem 

  17. RFC4306: 2.1. Use of Retransmission Timers