玩转华为ENSP模拟器系列 | 总部与分支结构之间建立IPSec VdPdNd(总部采用固定IP)
Posted COCOgsta
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了玩转华为ENSP模拟器系列 | 总部与分支结构之间建立IPSec VdPdNd(总部采用固定IP)相关的知识,希望对你有一定的参考价值。
素材来源:华为防火墙配置指南
一边学习一边整理试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:玩转华为ENSP模拟器系列 | 合集_COCOgsta的博客-CSDN博客_华为模拟器实验
目标
在实际的应用中,经常需要使用HUB-Spoke类型的组网,即一个总部到多个分支机构的组网,分支节点建立到总部的IPSec隧道,各个分支机构之间的通信由总部节点转发和控制。本举例中采用ISAKMP方式IPSec安全策略与IP固定的分支对接,采用模板方式的IPSec安全策略与IP不固定的分支对接。
组网需求
如图1所示,某企业分为总部(HQ)和两个分支机构(Branch 1和Branch 2)。组网如下:
- 分支机构1和分支机构2分别通过FW_B和FW_C与Internet相连。
- FW_A和FW_B、FW_A和FW_C相互路由可达。
- 总部FW_A和分支FW_B为固定公网地址,FW_C为动态公网IP地址。
要求实现如下需求:
- 分支机构PC2、PC3能与总部PC1之间进行安全通信。
- FW_A、FW_B以及FW_A、FW_C之间分别建立IPSec隧道。FW_B、FW_C不直接建立任何IPSec连接。
配置思路
- 完成接口基本配置、路由配置,并开启安全策略。
- 配置IPSec策略。包括配置IPSec策略的基本信息、配置待加密的数据流、配置安全提议的协商参数。
操作步骤
-
配置FW_A的基础配置。包括配置接口IP地址、接口加入安全区域、域间安全策略和静态路由。
- 配置接口IP地址。
-
<sysname> system-view [sysname] sysname FW_A [FW_A] interface gigabitethernet 1 / 0 / 3 [FW_A-GigabitEthernet1/0/3] ip address 10.1.1.1 24 [FW_A-GigabitEthernet1/0/3] quit [FW_A] interface gigabitethernet 1 / 0 / 1 [FW_A-GigabitEthernet1/0/1] ip address 1.1.3.1 24 [FW_A-GigabitEthernet1/0/1] quit 复制代码
- 配置接口加入相应的安全区域。
-
[FW_A] firewall zone trust [FW_A-zone-trust] add interface gigabitethernet 1 / 0 / 3 [FW_A-zone-trust] quit [FW_A] firewall zone untrust [FW_A-zone-untrust] add interface gigabitethernet 1 / 0 / 1 [FW_A-zone-untrust] quit 复制代码
- 配置Trust域与Untrust域之间的域间安全策略。
-
[FW_A] security-policy [FW_A-policy-security] rule name policy1 [FW_A-policy-security-rule-policy1] source-zone trust [FW_A-policy-security-rule-policy1] destination-zone untrust [FW_A-policy-security-rule-policy1] source-address 10.1.1.0 24 [FW_A-policy-security-rule-policy1] destination-address 10.1.2.0 24 [FW_A-policy-security-rule-policy1] destination-address 10.1.3.0 24 [FW_A-policy-security-rule-policy1] action permit [FW_A-policy-security-rule-policy1] quit [FW_A-policy-security] rule name policy2 [FW_A-policy-security-rule-policy2] source-zone untrust [FW_A-policy-security-rule-policy2] destination-zone trust [FW_A-policy-security-rule-policy2] source-address 10.1.2.0 24 [FW_A-policy-security-rule-policy2] source-address 10.1.3.0 24 [FW_A-policy-security-rule-policy2] destination-address 10.1.1.0 24 [FW_A-policy-security-rule-policy2] action permit [FW_A-policy-security-rule-policy2] quit 复制代码
- 配置Untrust域与Local域之间的域间安全策略。
-
[FW_A-policy-security] rule name policy3 [FW_A-policy-security-rule-policy3] source-zone local [FW_A-policy-security-rule-policy3] destination-zone untrust [FW_A-policy-security-rule-policy3] source-address 1.1.3.1 32 [FW_A-policy-security-rule-policy3] action permit [FW_A-policy-security-rule-policy3] quit [FW_A-policy-security] rule name policy4 [FW_A-policy-security-rule-policy4] source-zone untrust [FW_A-policy-security-rule-policy4] destination-zone local [FW_A-policy-security-rule-policy4] destination-address 1.1.3.1 32 [FW_A-policy-security-rule-policy4] action permit [FW_A-policy-security-rule-policy4] quit [FW_A-policy-security] quit 复制代码
- 配置到达分支机构的静态路由,此处假设下一跳地址为1.1.3.2。
-
[FW_A] ip route- static 0.0.0.0 0.0.0.0 1.1.3.2 复制代码
-
在FW_A上配置IPSec策略组,并在接口上应用IPSec策略组。
-
定义被保护的数据流。
- 配置高级ACL 3000,定义总部到分支机构1的数据流。
-
[FW_A] acl 3000 [FW_A-acl-adv-3000] rule 5 permit ip source 10.1.1.0 0.0.0.255 destination 10.1.2.0 0.0.0.255 [FW_A-acl-adv-3000] rule 10 permit ip source 10.1.2.0 0.0.0.255 destination 10.1.3.0 0.0.0.255 [FW_A-acl-adv-3000] quit 复制代码
- 配置高级ACL 3001,定义总部到分支机构2的数据流。
-
[FW_A] acl 3001 [FW_A-acl-adv-3001] rule 5 permit ip source 10.1.1.0 0.0.0.255 destination 10.1.3.0 0.0.0.255 [FW_A-acl-adv-3001] rule 10 permit ip source 10.1.3.0 0.0.0.255 destination 10.1.2.0 0.0.0.255 [FW_A-acl-adv-3001] quit 复制代码
-
配置IPSec安全提议。采用默认参数。
-
[FW_A] ipsec proposal tran1 [FW_A-ipsec-proposal-tran1] esp authentication-algorithm sha2- 256 [FW_A-ipsec-proposal-tran1] esp encryption-algorithm aes- 256 [FW_A-ipsec-proposal-tran1] quit 复制代码
-
配置IKE安全提议。采用默认参数。
-
[FW_A] ike proposal 10 [FW_A-ike-proposal-10] authentication-method pre-share [FW_A-ike-proposal-10] prf hmac-sha2- 256 [FW_A-ike-proposal-10] encryption-algorithm aes- 256 [FW_A-ike-proposal-10] dh group2 [FW_A-ike-proposal-10] integrity-algorithm hmac-sha2- 256 [FW_A-ike-proposal-10] quit 复制代码
-
配置IKE Peer。
- 配置名称为b的IKE Peer。
-
[FW_A] ike peer b [FW_A-ike-peer-b] ike-proposal 10 [FW_A-ike-peer-b] remote-address 1.1.5.1 [FW_A-ike-peer-b] pre-shared-key Test ! 1234 [FW_A-ike-peer-b] quit 复制代码
- 配置名称为c的IKE Peer。
-
[FW_A] ike peer c [FW_A-ike-peer-c] ike-proposal 10 [FW_A-ike-peer-c] pre-shared-key Test ! 1234 [FW_A-ike-peer-c] quit 复制代码
-
配置IPSec策略组map1的序号为10的IPSec策略。
-
[FW_A] ipsec policy map1 10 isakmp [FW_A-ipsec-policy-isakmp-map1-10] security acl 3000 [FW_A-ipsec-policy-isakmp-map1-10] proposal tran1 [FW_A-ipsec-policy-isakmp-map1-10] ike-peer b [FW_A-ipsec-policy-isakmp-map1-10] quit 复制代码
-
配置名称为map_temp序号为1的IPSec策略模板。
-
[FW_A] ipsec policy-template map_temp 1 [FW_A-ipsec-policy-templet-map_temp-1] security acl 3001 [FW_A-ipsec-policy-templet-map_temp-1] proposal tran1 [FW_A-ipsec-policy-templet-map_temp-1] ike-peer c [FW_A-ipsec-policy-templet-map_temp-1] quit 复制代码
-
在IPSec策略组map1的序号为20的安全策略中引用IPSec策略模板map_temp。
-
[FW_A] ipsec policy map1 20 isakmp template map_temp 复制代码
-
在接口GE1/0/1上应用IPSec策略组map1。
-
[FW_A] interface gigabitethernet 1 / 0 / 1 [FW_A-GigabitEthernet1/0/1] ipsec policy map1 [FW_A-GigabitEthernet1/0/1] quit 复制代码
-
-
配置FW_B的基础配置。
-
配置接口IP地址,并将接口加入域。
- 配置接口IP地址。
-
<sysname> system-view [sysname] sysname FW_B [FW_B] interface gigabitethernet 1 / 0 / 3 [FW_B-GigabitEthernet1/0/3] ip address 10.1.2.1 24 [FW_B-GigabitEthernet1/0/3] quit [FW_B] interface gigabitethernet 1 / 0 / 1 [FW_B-GigabitEthernet1/0/1] ip address 1.1.5.1 24 [FW_B-GigabitEthernet1/0/1] quit 复制代码
- 将接口GE1/0/3加入Trust区域,接口GE1/0/1加入Untrust区域
-
[FW_B] firewall zone trust [FW_B-zone-trust] add interface gigabitethernet 1 / 0 / 3 [FW_B-zone-trust] quit [FW_B] firewall zone untrust [FW_B-zone-untrust] add interface gigabitethernet 1 / 0 / 1 [FW_B-zone-untrust] quit 复制代码
-
配置域间安全策略。
- 配置Trust域与Untrust域之间的域间安全策略。
-
[FW_B] security-policy [FW_B-policy-security] rule name policy1 [FW_B-policy-security-rule-policy1] source-zone trust [FW_B-policy-security-rule-policy1] destination-zone untrust [FW_B-policy-security-rule-policy1] source-address 10.1.2.0 24 [FW_B-policy-security-rule-policy1] destination-address 10.1.1.0 24 [FW_B-policy-security-rule-policy1] action permit [FW_B-policy-security-rule-policy1] quit [FW_B-policy-security] rule name policy2 [FW_B-policy-security-rule-policy2] source-zone untrust [FW_B-policy-security-rule-policy2] destination-zone trust [FW_B-policy-security-rule-policy2] source-address 10.1.1.0 24 [FW_B-policy-security-rule-policy2] destination-address 10.1.2.0 24 [FW_B-policy-security-rule-policy2] action permit [FW_B-policy-security-rule-policy2] quit 复制代码
- 配置Untrust域与Local域之间的域间安全策略。
-
[FW_B-policy-security] rule name policy3 [FW_B-policy-security-rule-policy3] source-zone local [FW_B-policy-security-rule-policy3] destination-zone untrust [FW_B-policy-security-rule-policy3] source-address 1.1.5.1 32 [FW_B-policy-security-rule-policy3] destination-address 1.1.3.1 32 [FW_B-policy-security-rule-policy3] action permit [FW_B-policy-security-rule-policy3] quit [FW_B-policy-security] rule name policy4 [FW_B-policy-security-rule-policy4] source-zone untrust [FW_B-policy-security-rule-policy4] destination-zone local [FW_B-policy-security-rule-policy4] source-address 1.1.3.1 32 [FW_B-policy-security-rule-policy4] destination-address 1.1.5.1 32 [FW_B-policy-security-rule-policy4] action permit [FW_B-policy-security-rule-policy4] quit [FW_B-policy-security] quit 复制代码
-
配置到达总部和其他私网的静态路由,此处假设下一跳地址为1.1.5.2。
-
[FW_B] ip route- static 0.0.0.0 0.0.0.0 1.1.5.2 复制代码
-
-
在FW_B上配置IPSec策略,并在接口上应用IPSec策略。
- 定义被保护的数据流。
-
[FW_B] acl 3000 [FW_B-acl-adv-3000] rule 5 permit ip source 10.1.2.0 0.0.0.255 destination 10.1.1.0 0.0.0.255 [FW_B-acl-adv-3000] rule 10 permit ip source 10.1.2.0 0.0.0.255 destination 10.1.3.0 0.0.0.255 [FW_B-acl-adv-3000] quit 复制代码
- 配置名称为tran1的IPSec安全提议。采用默认参数。
-
[FW_B] ipsec proposal tran1 [FW_B-ipsec-proposal-tran1] esp authentication-algorithm sha2- 256 [FW_B-ipsec-proposal-tran1] esp encryption-algorithm aes- 256 [FW_B-ipsec-proposal-tran1] quit 复制代码
- 配置序号为10的IKE安全提议。采用默认参数。
-
[FW_B] ike proposal 10 [FW_B-ike-proposal-10] authentication-method pre-share [FW_B-ike-proposal-10] prf hmac-sha2- 256 [FW_B-ike-proposal-10] encryption-algorithm aes- 256 [FW_B-ike-proposal-10] dh group2 [FW_B-ike-proposal-10] integrity-algorithm hmac-sha2- 256 [FW_B-ike-proposal-10] quit 复制代码
- 配置IKE Peer。
-
[FW_B] ike peer a [FW_B-ike-peer-a] ike-proposal 10 [FW_B-ike-peer-a] remote-address 1.1.3.1 [FW_B-ike-peer-a] pre-shared-key Test ! 1234 [FW_B-ike-peer-a] quit 复制代码
- 配置名称为map1序号为10的IPSec策略。
-
[FW_B] ipsec policy map1 10 isakmp [FW_B-ipsec-policy-isakmp-map1-10] security acl 3000 [FW_B-ipsec-policy-isakmp-map1-10] proposal tran1 [FW_B-ipsec-policy-isakmp-map1-10] ike-peer a [FW_B-ipsec-policy-isakmp-map1-10] quit 复制代码
- 在GE1/0/1接口上应用IPSec策略map1。
-
[FW_B] interface gigabitethernet 1 / 0 / 1 [FW_B-GigabitEthernet1/0/1] ipsec policy map1 [FW_B-GigabitEthernet1/0/1] quit 复制代码
-
配置FW_C的基础配置。
-
配置接口IP地址,并将接口加入域。
- 配置GE1/0/3的IP地址为10.1.3.1/24;配置GE1/0/1通过DHCP动态获取IP地址。
-
<sysname> system-view [sysname] sysname FW_C [FW_C] interface gigabitethernet 1 / 0 / 3 [FW_C-GigabitEthernet1/0/3] ip address 10.1.2.1 24 [FW_C-GigabitEthernet1/0/3] quit [FW_C] interface gigabitethernet 1 / 0 / 1 [FW_C-GigabitEthernet1/0/1] ip address dhcp-alloc [FW_C-GigabitEthernet1/0/1] quit 复制代码
- 将接口GE1/0/3加入Trust区域,接口GE1/0/1加入Untrust区域
-
[FW_C] firewall zone trust [FW_C-zone-trust] add interface gigabitethernet 1 / 0 / 3 [FW_C-zone-trust] quit [FW_C] firewall zone untrust [FW_C-zone-untrust] add interface gigabitethernet 1 / 0 / 1 [FW_C-zone-untrust] quit 复制代码
-
配置域间安全策略。
- 配置Trust域与Untrust域之间的域间安全策略。
-
[FW_C] security-policy [FW_C-policy-security] rule name policy1 [FW_C-policy-security-rule-policy1] source-zone trust [FW_C-policy-security-rule-policy1] destination-zone untrust [FW_C-policy-security-rule-policy1] source-address 10.1.3.0 24 [FW_C-policy-security-rule-policy1] destination-address 10.1.1.0 24 [FW_C-policy-security-rule-policy1] action permit [FW_C-policy-security-rule-policy1] quit [FW_B-policy-security] rule name policy2 [FW_C-policy-security-rule-policy2] source-zone untrust [FW_C-policy-security-rule-policy2] destination-zone trust [FW_C-policy-security-rule-policy2] source-address 10.1.1.0 24 [FW_C-policy-security-rule-policy2] destination-address 10.1.3.0 24 [FW_C-policy-security-rule-policy2] action permit [FW_C-policy-security-rule-policy2] quit 复制代码
- 配置Untrust域与Local域之间的域间安全策略。
-
[FW_C-policy-security] rule name policy3 [FW_C-policy-security-rule-policy3] source-zone local [FW_C-policy-security-rule-policy3] destination-zone untrust [FW_C-policy-security-rule-policy3] destination-address 1.1.3.1 32 [FW_C-policy-security-rule-policy3] destination-address 1.1.3.1 32 [FW_C-policy-security-rule-policy3] action permit [FW_C-policy-security-rule-policy3] quit [FW_C-policy-security] rule name policy4 [FW_C-policy-security-rule-policy4] source-zone untrust [FW_C-policy-security-rule-policy4] destination-zone local [FW_C-policy-security-rule-policy4] source-address 1.1.3.1 32 [FW_C-policy-security-rule-policy4] action permit [FW_C-policy-security-rule-policy4] quit [FW_C-policy-security] quit 复制代码
-
配置到达总部和其他私网的静态路由。
-
[FW_C] ip route- static 0.0.0.0 0.0.0.0 GigabitEthernet 1 / 0 / 1 复制代码
-
-
在FW_C上配置IPSec策略,并在接口上应用此安全策略。
- 定义被保护的数据流。
-
[FW_C] acl 3000 [FW_C-acl-adv-3000] rule 5 permit ip source 10.1.3.0 0.0.0.255 destination 10.1.1.0 0.0.0.255 [FW_C-acl-adv-3000] rule 10 permit ip source 10.1.3.0 0.0.0.255 destination 10.1.2.0 0.0.0.255 [FW_C-acl-adv-3000] quit 复制代码
- 配置名称为tran1的IPSec安全提议。采用默认参数。
-
[FW_C] ipsec proposal tran1 [FW_C-ipsec-proposal-tran1] esp authentication-algorithm sha2- 256 [FW_C-ipsec-proposal-tran1] esp encryption-algorithm aes- 256 [FW_C-ipsec-proposal-tran1] quit 复制代码
- 配置序号为10的IKE安全提议。采用默认参数。
-
[FW_C] ike proposal 10 [FW_C-ike-proposal-10] authentication-method pre-share [FW_C-ike-proposal-10] prf hmac-sha2- 256 [FW_C-ike-proposal-10] encryption-algorithm aes- 256 [FW_C-ike-proposal-10] dh group2 [FW_C-ike-proposal-10] integrity-algorithm hmac-sha2- 256 [FW_C-ike-proposal-10] quit 复制代码
- 配置IKE Peer。
-
[FW_C] ike peer a [FW_C-ike-peer-a] ike-proposal 10 [FW_C-ike-peer-a] remote-address 1.1.3.1 [FW_C-ike-peer-a] pre-shared-key Test ! 1234 [FW_C-ike-peer-a] quit 复制代码
- 配置名称为map1序号为10的IPSec策略。
-
[FW_C] ipsec policy map1 10 isakmp [FW_C-ipsec-policy-isakmp-map1-10] security acl 3000 [FW_C-ipsec-policy-isakmp-map1-10] proposal tran1 [FW_C-ipsec-policy-isakmp-map1-10] ike-peer c [FW_C-ipsec-policy-isakmp-map1-10] quit 复制代码
- 在GE1/0/1接口上应用IPSec策略map1。
-
[FW_C] interface gigabitethernet 1 / 0 / 1 [FW_C-GigabitEthernet1/0/1] ipsec policy map1 [FW_C-GigabitEthernet1/0/1] quit 复制代码
结果验证
- 配置完成后,PC2、PC1可以互相访问,双方都可以触发建立IPSec SA。PC3能够主动访问PC1,只有PC3的FW_C能够触发IPSec SA,之后PC1能够访问到PC3,在PC3能够访问PC1之后,PC2与PC3能够实现互访。
- 在总部防火墙FW_A上可以查看到两对IKE SA。
<FW_A> display ike sa
Ike sa information :
Conn-ID Peer VPN Flag(s) Phase
------------------------------------------------------------------------------
50336907 1.1.5.1 RD|ST|A v2:2
50336906 1.1.5.1 RD|ST|A v2:1
33554436 1.1.6.254 RD|A v2:2
33554435 1.1.6.254 RD|A v2:1
Number of SA entries : 4
Number of SA entries of all cpu : 4
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
复制代码
- 分支FW_B和FW_C上可以查看到对端为总部的IKE SA。下面以FW_B为例进行说明。
<FW_B> display ike sa
Ike sa information :
Conn-ID Peer VPN Flag(s) Phase
------------------------------------------------------------------------------
16782416 1.1.3.1 RD|A v2:2
16782415 1.1.3.1 RD|A v2:1
Number of SA entries : 2
Number of SA entries of all cpu : 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
复制代码
- 在总部FW_A上可以查看到两对双向的IPSec SA,分别是对应两个分支FW_B和FW_C。
<FW_A> display ipsec sa brief
Current ipsec sa num:4
Number of SAs:4
Src address Dst address SPI VPN Protocol Algorithm
-------------------------------------------------------------------------------
1.1.6.254 1.1.3.1 4001819557 ESP E:AES-256 A:SHA2-256-128
1.1.5.1 1.1.3.1 3923280450 ESP E:AES-256 A:SHA2-256-128
1.1.3.1 1.1.6.254 4249128694 ESP E:AES-256 A:SHA2-256-128
1.1.3.1 1.1.5.1 787858613 ESP E:AES-256 A:SHA2-256-128
复制代码
- 分支节点FW_B和FW_C上可以查看到FW_A的一对反向IPSec SA。下面以FW_B上的显示为例。
<FW_B> display ipsec sa brief
Current ipsec sa num:2
Number of SAs:2
Src address Dst address SPI VPN Protocol Algorithm
-------------------------------------------------------------------------------
1.1.5.1 1.1.3.1 3923280450 ESP E:AES-256 A:SHA2-256-128
1.1.3.1 1.1.5.1 787858613 ESP E:AES-256 A:SHA2-256-128
以上是关于玩转华为ENSP模拟器系列 | 总部与分支结构之间建立IPSec VdPdNd(总部采用固定IP)的主要内容,如果未能解决你的问题,请参考以下文章
玩转华为ENSP模拟器系列 | 两个网关之间存在NAT设备时通过IKE方式协商IPSec VdPdNd隧道(总部通过Name认证分支)
玩转华为ENSP模拟器系列 | 两个网关之间存在NAT设备时通过IKE方式协商IPSec VdPdNd隧道(总部不指定分支IP地址)
玩转华为ENSP模拟器系列 | 两个网关之间存在NAT设备时通过IKE方式协商IPSec VdPdNd隧道(总部通过NAT前的IP认证分支)
玩转华为ENSP模拟器系列 | 两个网关之间通过IPSec VdPdNd互联并通过总部IPSec网关进行NAT后上网