zl程序教程

您现在的位置是:首页 >  前端

当前栏目

HCIE-Security Day30:IPSec:实验(五)配置基于路由的IPSec PN(采用预共享密钥认证)

配置路由认证 基于 共享 实验 采用 Security
2023-09-11 14:14:52 时间

 

IPSec是基于定义的感兴趣流触发对特定数据的保护,至于什么样的数据是需要IPSec保护的,可以通过以下两种方式定义。其中IPSec感兴趣流即需要IPSec保护的数据流。

此前使用的都是acl方式定义的感兴趣流。

还有一种方式是路由方式。

通过ipsec虚拟隧道接口建立ipsec隧道,将所有路由到ipsec虚拟隧道接口的报文都进行ipsec保护,根据该路由的目的地址确定哪些数据流需要ipsec保护,其中ipsec虚拟隧道接口具有以下优点。

简化配置:不需使用acl定义流量特征

支持动态路由协议

通过gre over ipsec支持对组播流量的保护

虚拟隧道接口(即tunnel接口)是一种三层逻辑接口,通过配置tunnel接口,并在tunnel接口上应用ipsec安全框架建立ipsec隧道。在tunnel接口上应用ipsec安全框架后,系统只会生成一条ipsec隧道,并对所有路由到该隧道接口的数据流进行ipsec保护。

ipsec的tunnel接口的ip地址可以手工配置,可以ikev2协商申请。后者适用于大规模分支接入总部场景。

需求和拓扑

网络A和网络B分别通过FW_A和FW_B连接到Internet。网络环境描述如下:

  • 网络A属于10.1.1.0/24子网,通过接口GigabitEthernet 0/0/3与FW_A连接。

  • 网络B属于10.1.2.0/24子网,通过接口GigabitEthernet 0/0/3与FW_B连接。

  • FW_A和FW_B路由可达。

通过组网实现如下需求:在FW_A和FW_B之间建立基于路由的IPSec隧道,使网络A和网络B的用户可通过IPSec隧道互相访问。

操作步骤

1、配置接口地址和安全区域

2、配置公网路由可达

3、配置安全策略全通

4、配置tunnel接口

//f1
interface Tunnel1
 ip address 172.16.1.2 255.255.255.0
 tunnel-protocol ipsec
 source 1.1.3.1
 destination 1.1.5.1


//f2
interface Tunnel1
 ip address 172.16.2.2 255.255.255.0
 tunnel-protocol ipsec
 source 1.1.5.1
 destination 1.1.3.1

 4.1、配置路由,将需要经过ipsec隧道传输的流量引入ipsec隧道中。

//f1
ip route-static 10.1.2.0 255.255.255.0 Tunnel1
//f2
ip route-static 10.1.1.0 255.255.255.0 Tunnel1

5、配置ipsec 

5.1、配置ipsec安全提议

ipsec proposal tran1
 esp authentication-algorithm sha2-256
 esp encryption-algorithm aes-256

5.2、配置ike安全提议

ike proposal 10
 encryption-algorithm aes-256
 dh group14
 authentication-algorithm sha2-256
 authentication-method pre-share
 integrity-algorithm hmac-sha2-256
 prf hmac-sha2-256

5.3、配置ike peer(注意不配remote-address)

//f1
ike peer b
 pre-shared-key Test!1234
 ike-proposal 10
//f2
ike peer a
 pre-shared-key Test!1234
 ike-proposal 10

5.4、配置ipsec安全框架

ipsec安全框架定义了对数据流的保护方法,比如使用的ipsec安全提议、自动协商sa的ike协商参数、sa的生存周期等。一个ipsec安全框架相当一个ipsec安全策略,但是与ipsec安全策略不同的是:安全框架由名称唯一确定,且只能通过ike协商方式配置。

为了保证ike协商成功,安全框架中所有配置的参数都必须在本端和对端相匹配。

ipsec安全框架无需通过acl定义数据流,而是保护所有引入到ipsec隧道即tunnel的数据流。

//f1
ipsec profile pro1
 ike-peer b  
 proposal tran1
//f2
ipsec profile pro1
 ike-peer a
 proposal tran1

5.5、在tunnel接口上应用ipsec安全框架

在ipsec虚拟隧道接口下应用ipsec安全框架后只会生成一条ipsec隧道,并对所有路由到该隧道接口的数据流进行ipsec保护,简化了安全策略管理的复杂度。

interface tunnel 1
ipsec profile pro1

验证和分析

1、检查ike sa和ipsec sa的建立情况

[f2]dis ike sa
2022-03-20 14:15:26.690 

IKE SA information :
 Conn-ID    Peer                                          VPN              Flag(
s)               Phase  RemoteType  RemoteID        
--------------------------------------------------------------------------------
----------------------------------------------------
 15         1.1.3.1:500                                                    RD|ST
|A               v2:2   IP          1.1.3.1         
 14         1.1.3.1:500                                                    RD|ST
|A               v2:1   IP          1.1.3.1         

  Number of IKE SA : 2
--------------------------------------------------------------------------------
----------------------------------------------------

 Flag Description:
 RD--READY   ST--STAYALIVE   RL--REPLACED   FD--FADING   TO--TIMEOUT
 HRT--HEARTBEAT   LKG--LAST KNOWN GOOD SEQ NO.   BCK--BACKED UP
 M--ACTIVE   S--STANDBY   A--ALONE  NEG--NEGOTIATING

[f2]dis ipsec sa brief 
2022-03-20 14:15:42.870 

IPSec SA information:
   Src address                             Dst address                          
   SPI
   VPN                                     Protocol                             
   Algorithm
 -------------------------------------------------------------------------------
-------------------------------------------
   1.1.3.1                                 1.1.5.1                              
   186134018 
                                           ESP                                  
   E:AES-256 A:SHA2_256_128
   1.1.5.1                                 1.1.3.1                              
   196568654 
                                           ESP                                  
   E:AES-256 A:SHA2_256_128

  Number of IPSec SA : 2
 -------------------------------------------------------------------------------
------------------------------------