华为防火墙基础自学系列 | IKE介绍

发布于:2022-12-25 ⋅ 阅读:(516) ⋅ 点赞:(0)

视频来源:B站《乾颐堂HCIP-HCIE-security安全 2019年录制》

一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!

附上汇总贴:华为防火墙基础自学系列 | 汇总_COCOgsta的博客-CSDN博客


什么是SA(安全关联)

A security association, more commonly referred to as an SA, is a basic building block of IPSec. An SA is an entry in the SA database (SADB) , which contains information about the security that has been negotiated between two parties for IKE or IPSec. There are two types of SAs:(SA是IPSec的一个基本组成部分,SA是SADB的一个条目, 它包含双方关于IKE和IPSec已经协商完毕的安全信息)

  • IKE or ISAKMP SA(1.双向的 2.决定了IKE协议处理相关细节)
  • IPSec SA(1.单向的 2.与封装协议相关 3.决定了具体加密流量的处理方式)

Although it is common practice to use the term SA to encompass both types, it is important to make the distinction for troubleshooting purposes, because each type of SA achieves a different purpose. Both SA types are established between IPSec peers using the IKE protocol.(两种类型的SA都由IKE协议协商产生)

IKE介绍

IKE负责建立和维护IKE SAs和IPSec SAs。功能主要体现在如下几个方面:

  • 对双方进行认证
  • 交换公共密钥,产生密钥资源,管理密钥
  • 协商协议参数(封装,加密,验证。。。)

IKE的三个模式

主模式和野蛮模式交换过程图

野蛮模式与主模式对比

IKEv1建立IKE SA的过程定义了主模式(Main Mode)和野蛮模式(Aggressive Mode)两种交换模式。

主模式包含三次双向交换,用到了六条信息。

  • 消息1和消息2用于策略交换;
  • 消息3和消息4用于密钥信息交换;
  • 消息5和消息6用于身份和认证信息交换。

野蛮模式只用到三条信息。

  • 前两条消息1和2用于协商提议,消息3用于响应认证发起方。

快速模式(Quick Mode)

快速模式中,双方需要协商生成IPSec SA各项参数(包含可选参数PFS),并为IPSec SA生成认证/加密密钥。这在快速模式交换的前两条消息1和2中完成。消息3为确认信息,用于确认发送方收到该阶段的消息2,验证响应者是否可以通信。

快速模式交换过程图

主模式与野蛮模式区别(面试题)

  1. 交换的消息:主模式为6个消息,野蛮模式为3个消息,野蛮模式能够更快创建IKE SA
  1. NAT支持:对预共享密钥认证:主模式不支持NAT转换(没有开启NAT-T),而野蛮模式支持(不开启NAT-T)。而对于证书方式认证:两种模式都能支持。
  1. 对等体标识:主模式只能采用IP地址方式标识对等体;而野蛮模式可以采用IP地址方式或者Name方式标识对等体(DN FQDN User-FQDN)。这是由于主模式在交换完3、4消息以后,需要使用预共享密钥来计算SKEYID(pre-share-key Ni | Nr),当一个设备有多个对等体时,必须查找到该对等体对应的预共享密钥,但是由于其对等体的ID信息在消息5、6中才会发送,此时主模式的设备只能私用3、4中的IP报文源地址来找到与其对应的预共享密钥;如果主模式采用Name方式,Name信息却包含在消息5、6中,而设备必须在消息5、6之前找到其对等体的预共享密钥,所以就造成了矛盾,无法完成Name方式的标识。(主模式只支持IP地址方式标识对等体,不支持Name方式) 而在野蛮模式中,ID消息在消息1、2中就已经发送了,设备可以根据ID信息查找到对应的预共享密钥,从而计算SKEYID。但是由于野蛮模式交换的2个消息没有经过加密,所以ID信息也是明文的,也相应造成了安全隐患。(野蛮支持IP地址方式标识对等体,也可以NAME方式,但是ID是明文的,不安全,华为推荐使用模板方式)
  1. 提议转换对数量:在野蛮模式中,由于第一个消息就需要交换DH消息,而DH消息本身就决定了采用哪个DH组,这样在提议转换对中就确定了使用哪个DH组,如果第一个消息中包含多个提议转换对,那么这多个转换对的DH组必须相同(和DH消息确定的DH组一致),否则消息1中只能携带和确定DH组相同的提议转换对。
  1. 协商能力:由于野蛮模式交换次数的限制,因此野蛮模式协商能力低于主模式。
  1. 主模式的认证是在加密的环境下进行的,野蛮模式在非加密环境下进行;野蛮模式采用预共享密钥的场景下不依赖于IP地址的标示,因此支持动态IP地址的场景。(应用场景角度)
  1. 主模式常用,野蛮已经不推荐使用(华为野蛮模式必须配置remote-address,考虑安全问题)
  1. 两者之间的协商过程不同(展开说) 主模式6个消息,具体1-2做啥、3-4做啥、5-6做啥

IKEv2简介

Defined in RFC 4306 - updated by RFC 5996

  1. 不兼容IKEv1
  1. 尚未被广泛使用

Both are using the same basic structure aiming at:

  1. Privacy(私密性)
  1. integrity(完整性)
  1. Authentication(源认证)

Both run over UDP 500/4500

IKEv2 RFC 5996

IKEv1 VS IKEv2

IKEv2初始交换过程图

IKE_SA_INIT介绍

The first exchange, IKE_SA_INIT, is used to negotiate the security parameters(协商安全参数)by sending IKEv2 proposals, including the configured encryption and integrity protocols, DH values, and nonces (random) numbers(配置的加密和完整性校验协议,DH公共值和随机数). At this point, the two peers generate SKEYSEED (a seed security key value) from which all future IKE keys are generated. The messages that follow in later exchanges are encrypted and authenticated(后续的信息被加密和验证)using keys also generated from the SKEYSEED value.

IKE_SA_INIT:Message 1

发起方提供基本的SA(安全关联)参数和密钥交换材料。(等同于IKEv1的MM1和MM3两个包)

  • HDR - IKE Header(IKE头部)
  • SAi - Cryptographic algorithms proposed by initiator(发起方提供的密码学算法)
  • KEi - Initiator key exchange material(发起方提供的密钥交换材料、优先使用最高安全级别的DH组)
  • Ni - Initiator nonce(发起方随机数)

IKE_SA_INIT:Message 2

接收方发回一个可以接受的参数,并附带密钥交换内容和证书请求(可选项)。(等同于IKEv1的MM2和MM4)

  • HDR - IKE Header(IKE头部)
  • SAr - Cryptographic algorithms chosen by responder(接收方提供的密码学算法)
  • KEr - Responder key exchange material(接收方选择的密钥交换材料)
  • Nr - responder nonce(接收方随机数)
  • CertReq - Certificate request(optional)(证书请求(可选))

IKE_AUTH介绍

The second exchange, IKE_AUTH, operates over the IKE_SA created by the IKE_SA_INIT(操作在由IKE_SA_INIT所创建的IKE_SA之上)exchanges and is used to validate the identity of the peers and negotiate the various encryption, authentication, and integrity protocols to establish the first CHILD_SA(协商各种加密,验证和完整性校验协议,用于建立第一个CHILD_SA)for use by ESP or AH in which IPsec communication occurs. Peers are validated using pre-shared keys, certificates, or Extensible Authentication Protocol (EAP) (allowing for legacy authentication methods between peers).

IKE_AUTH:Message 1

创建child SA相关的认证内容和参数(等同于IKEv1的MM5和部分QM)

  • SK - Payload encrypted and integrity protected(负载被加密并且完整性保护)
  • IDi - Initiator Identity(发起方的身份信息)
  • Cert - Initiator certificate (optional)(发起方的证书)(可选)
  • CertReq - Certificate request (optional)(发起方的证书请求)(可选)
  • IDr - Expected responder identity (optional)(期望的响应方的身份信息)(可选)
  • AUTH - Initiator authentication data(发起方认证数据,没有EAP就么有这个字段)(可选)
  • SAi2 - Child SA transform proposed by initiator(发起方Child SA转换集)
  • TSi/TSr - Child SA traffic selectors (src/dst proxies)(Child SA流量选择器)

IKE_AUTH:Message 2

创建于child SA相关的认证内容和参数(等同于MM6和部分QM)

  • SK - Payload encrypted and integrity protected(负载被加密并且完整性保护)
  • IDr - Responder Identity(响应方的身份信息)
  • Cert - Responder certificate (Optional)(响应方的证书)(可选)
  • AUTH - Responder authentication data(响应方的认证数据,没有EAP就没有这个字段)(可选)
  • SAr2 - Child SA transforms Selected by responder(响应方选择的Child SA转换集)
  • TSi/Tsr - Child SA traffic selectors (src/dst proxies)(Child SA流量选择器,感兴趣流)

IKE安全机制

身份认证

身份保护

DH(Diffie-Hellman)密钥交换算法

完善的前向安全性PFS(Perfect Forward Secrecy)

身份认证

确认通信双方的身份(对等体的IP地址或名称),包括:

  • 预共享密钥PSK(pre-shared key)认证。
  • 数字签名RSA(rsa-signature)认证。

实验

SW1

vlan batch 10 16 20 40
interface Ethernet0/0/4
  description Link_FW1_G0/0/0
  port link-type access
  port default vlan 16
interface Ethernet0/0/8
  description Link_FW2_G0/0/0
  port link-type access
  port default vlan 16
interface Ethernet0/0/21
  description Link_HCNP_MGMT
  port link-type access
  port default vlan 16
interface Ethernet0/0/1
  description Link_FW1_G0/0/1
  port link-type access
  port default vlan 10
interface Ethernet0/0/9
  description Link_HCNP_Dot1x(PC1)
  port link-type access
  port default vlan 10
interface Ethernet0/0/5
  description Link_FW2_G0/0/1
  port link-type access
  port default vlan 20
interface Ethernet0/0/24
  description Link_HCNP_VPN_Client(PC2)
  port link-type access
  port default vlan 20
interface Ethernet0/0/2
  description Link_FW1_G0/0/2
  port link-type access
  port default vlan 40
interface Ethernet0/0/23
  description Link_HCNP_Untrust
  port link-type access
  port default vlan 40
interface Ethernet0/0/6
  description Link_FW2_G0/0/2
  port link-type access
  port default vlan 40
复制代码

FW1

interface g0/0/1
  ip address 10.1.1.10 24
interface g0/0/2
  ip address 202.100.1.10 24
firewall zone untrust
  add int g0/0/2
firewall zone trust 
  add int g0/0/1
ip route-static 0.0.0.0 0.0.0.0 202.100.1.11
interface g0/0/0
  ip address 192.168.0.10 24
// 图形化配置结果
acl number 3000
  rule 5 permit ip source 10.1.1.0 0.0.0.255 destination 10.1.2.0 0.0.0.255
ike proposal 1
  authentication-algorithm sha2-256
  integrity-algorithm aes-xcbc-96 hmac-sha2-256
ike peer ike108112531427
  exchange-mode auto
  pre-shared-key Huawei@123
  ike-proposal 1
  undo version 1
  remote-id-type none
  remote-address 202.100.1.1
 ipsec proposal prop10811253142
   esp authentication-algorithm sha2-256
 ipsec policy ipsec1081125314 1 isakmp
   security acl 3000
   ike-peer ike108112531427
   alias ipsec_policy
   proposal prop10811253142
   local-address applied-interface
   sa duration traffic-based 200000000
   sa duration time-based 3600
 interface GigabitEthernet0/0/2
   ipsec policy ipsec1081125314 auto-neg
复制代码

FW2

interface g0/0/1
  ip address 10.1.2.10 24
interface g0/0/2
  ip address 202.100.1.11 24
  service-manage ping permit
firewall zone untrust 
  add int g0/0/2
firewall zone trust
  add int g0/0/1
interface g0/0/0
  ip address 192.168.0.11 24
ip route-static 0.0.0.0 0.0.0.0 202.100.1.10
复制代码

本文含有隐藏内容,请 开通VIP 后查看