玩转华为ENSP模拟器系列 | 两个网关之间存在NAT设备时通过IKE方式协商IPSec VdPdNd隧道(总部通过Name认证分支)
Posted COCOgsta
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了玩转华为ENSP模拟器系列 | 两个网关之间存在NAT设备时通过IKE方式协商IPSec VdPdNd隧道(总部通过Name认证分支)相关的知识,希望对你有一定的参考价值。
素材来源:华为防火墙配置指南
一边学习一边整理试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:玩转华为ENSP模拟器系列 | 合集_COCOgsta的博客-CSDN博客_华为模拟器实验
目标
在实际组网应用中,如果发起者位于一个私网内部,而它希望在自己与远端响应者之间直接建立一条IPSec隧道,这种情况会对部署IPSec VPN网络造成障碍。这就需要IPSec与NAT进行结合。
组网需求
图1所示的网络环境如下:
- 总部属于10.1.1.0/24子网,通过接口GE1/0/1与FW_A连接。
- 分支机构属于10.1.2.0/24子网,通过接口GE1/0/1与FW_C连接。
- FW_A和FW_C路由可达。
- FW_B为NAT网关,分支用户必须经过NAT网关才能访问总部。
分支机构的员工需要访问总部的服务器。由于服务器信息较机密,数据经过Internet传输不安全,故需建立IPSec隧道来对传输数据进行加密。
配置思路
- 总部和分支机构的网关之间存在NAT设备,此时在总部配置ISAKMP方式IPSec安全策略,采用对端名称认证分支。
- 配置IPSec安全提议时,安全协议必须采用ESP协议,ESP协议为安全协议的默认配置,可以不配置。
操作步骤
-
配置FW_A的基础配置。
-
基础配置。
- 配置接口IP地址。
-
<sysname> system-view [sysname] sysname FW_A [FW_A] interface gigabitethernet 1 / 0 / 1 [FW_A-GigabitEthernet1/0/1] ip address 10.1.1.1 24 [FW_A-GigabitEthernet1/0/1] quit [FW_A] interface gigabitethernet 1 / 0 / 2 [FW_A-GigabitEthernet1/0/2] ip address 1.1.2.1 24 [FW_A-GigabitEthernet1/0/2] quit 复制代码
- 将接口加入相应的安全区域。
-
[FW_A] firewall zone trust [FW_A-zone-trust] add interface gigabitethernet 1 / 0 / 1 [FW_A-zone-trust] quit [FW_A] firewall zone untrust [FW_A-zone-untrust] add interface gigabitethernet 1 / 0 / 2 [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] 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] 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.2.1 32 [FW_A-policy-security-rule-policy3] destination-address 1.1.5.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] source-address 1.1.5.1 32 [FW_A-policy-security-rule-policy4] destination-address 1.1.2.1 32 [FW_A-policy-security-rule-policy4] action permit [FW_A-policy-security-rule-policy4] quit [FW_A-policy-security] quit 复制代码
-
配置到达分支机构的静态路由,此处假设下一跳地址为1.1.2.2。
-
[FW_A] ip route- static 10.1.2.0 255.255.255.0 1.1.2.2 [FW_A] ip route- static 10.1.5.0 255.255.255.0 1.1.2.2 复制代码
-
-
在FW_A上配置IPSec。
- 定义被保护的数据流。
-
[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] quit 复制代码
- 配置IPSec安全提议tran1。采用默认参数。
-
[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。
-
[FW_A] ike peer c [FW_A-ike-peer-c] ike-proposal 10 [FW_A-ike-peer-c] local-id-type ip [FW_A-ike-peer-c] remote-id-type fqdn [FW_A-ike-peer-c] remote-id branch [FW_A-ike-peer-c] remote-address 1.1.5.1 [FW_A-ike-peer-c] pre-shared-key Test ! 1234 [FW_A-ike-peer-c] quit 复制代码
- 配置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 c [FW_A-ipsec-policy-isakmp-map1-10] quit 复制代码
- 在接口GE1/0/2上应用IPSec策略组map1。
-
[FW_A] interface GigabitEthernet 1 / 0 / 2 [FW_A-GigabitEthernet1/0/2] ipsec policy map1 [FW_A-GigabitEthernet1/0/2] quit 复制代码
-
配置FW_C的基础配置。
-
配置接口IP地址,并将接口加入域。 请根据图1的数据配置接口IP地址。 将接口GE1/0/1加入Trust区域,接口GE1/0/2加入Untrust区域。 详细步骤可参见FW_A的配置。
-
配置域间安全策略。
- 配置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.2.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_C-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.2.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] source-address 10.1.5.2 32 [FW_C-policy-security-rule-policy3] destination-address 1.1.2.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.2.1 32 [FW_C-policy-security-rule-policy4] destination-address 10.1.5.2 32 [FW_C-policy-security-rule-policy4] action permit [FW_C-policy-security-rule-policy4] quit [FW_C-policy-security] quit 复制代码
-
配置达到总部的静态路由,下一跳地址为10.1.5.1。
-
[FW_C] ip route- static 10.1.1.0 255.255.255.0 10.1.5.1 [FW_C] ip route- static 1.1.2.0 255.255.255.0 10.1.5.1 复制代码
-
-
在FW_C上配置IPSec策略。
- 定义被保护的数据流。
-
[FW_C] acl 3000 [FW_C-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_C-acl-adv-3000] quit 复制代码
- 配置IPSec安全提议tran1。采用默认参数。
-
[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 复制代码
- 配置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] local-id-type fqdn [FW_C-ike-peer-a] remote-id-type ip [FW_C-ike-peer-a] local-id branch [FW_C-ike-peer-a] remote-address 1.1.2.1 [FW_C-ike-peer-a] pre-shared-key Test ! 1234 [FW_C-ike-peer-a] quit 复制代码
- 配置IPSec策略map1。
-
[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 a [FW_C-ipsec-policy-isakmp-map1-10] quit 复制代码
- 在接口GE1/0/2上应用IPSec策略组map1。
-
[FW_C] interface GigabitEthernet 1 / 0 / 2 [FW_C-GigabitEthernet1/0/2] ipsec policy map1 [FW_C-GigabitEthernet1/0/2] quit 复制代码
-
配置FW_B(配置NAT网关)。
- 基础配置。 请根据图1的数据配置接口IP地址。 将接口GE1/0/1加入Untrust区域,接口GE1/0/2加入Trust区域。 详细步骤可参见FW_A的配置。
- 配置域间安全策略。
-
[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.5.2 32 [FW_B-policy-security-rule-policy1] destination-address 1.1.2.1 32 [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 1.1.2.1 32 [FW_B-policy-security-rule-policy2] destination-address 10.1.5.2 32 [FW_B-policy-security-rule-policy2] action permit [FW_B-policy-security-rule-policy2] quit [FW_B-policy-security] quit 复制代码
- 配置NAT。
-
[FW_B] nat-policy [FW_B-policy-nat] rule name policy_nat1 [FW_B-policy-nat-rule-policy_nat1] source-zone trust [FW_B-policy-nat-rule-policy_nat1] destination-zone untrust [FW_B-policy-nat-rule-policy_nat1] source-address 10.1.5.0 24 [FW_B-policy-nat-rule-policy_nat1] action nat easy-ip [FW_B-policy-nat-rule-policy_nat1] quit [FW_B-policy-nat] quit 复制代码
- 配置到总部网络和分支网络的静态路由。
-
[FW_B] ip route- static 10.1.1.0 255.255.255.0 1.1.5.2 [FW_B] ip route- static 10.1.2.0 255.255.255.0 10.1.5.2 复制代码
结果验证
- 配置完成后,PC2发起访问,之后PC1与PC2之间可以相互访问。PC2同时可以访问到公网。
- PC2可以Ping通FW_A的1.1.2.1,同时在FW_B上可以查看NAT转换session表项。
<FW_B> display firewall session table
Current Total Sessions : 2
udp VPN:public --> public 10.1.5.2:500[1.1.5.1:2048]-->1.1.2.1:500
udp VPN:public --> public 10.1.5.2:4500[1.1.5.1:2048]-->1.1.2.1:4500
复制代码
- 总部防火墙FW_A上可以查看到对应的IKE SA。
<FW_A> display ike sa
Ike sa information :
Conn-ID Peer VPN Flag(s) Phase
---------------------------------------------------------------
83887864 1.1.5.1 RD|A v2:2
83887652 1.1.5.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_C可以查看到对端为总部的IKE SA,FW_C是发起方,标志位为ST。
<FW_C> display ike sa
Ike sa information :
Conn-ID Peer VPN Flag(s) Phase
---------------------------------------------------------------
62887864 1.1.2.1 RD|ST|A v2:2
62887652 1.1.2.1 RD|ST|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_C。
<FW_A> display ipsec sa brief
Current ipsec sa num:2
Spu board slot 1, cpu 1 ipsec sa information:
Number of SAs:2
Src address Dst address SPI VPN Protocol Algorithm
-------------------------------------------------------------------------------
1.1.2.1 1.1.5.1 3923280450 ESP E:AES-256 A:SHA2_256_128
1.1.5.1 1.1.2.1 2676437093 ESP E:AES-256 A:SHA2_256_128
复制代码
- 分支节点FW_C上可以查看到一对双向IPSec SA。
<FW_A> display ipsec sa brief
Current ipsec sa num:2
Spu board slot 1, cpu 1 ipsec sa information:
Number of SAs:4
Src address Dst address SPI VPN Protocol Algorithm
-------------------------------------------------------------------------------
10.1.5.2 1.1.2.1 2179965693 ESP E:AES-256 A:SHA2_256_128
1.1.2.1 10.1.5.2 3813759530 ESP E:AES-256 A:SHA2_256_128
以上是关于玩转华为ENSP模拟器系列 | 两个网关之间存在NAT设备时通过IKE方式协商IPSec VdPdNd隧道(总部通过Name认证分支)的主要内容,如果未能解决你的问题,请参考以下文章
玩转华为ENSP模拟器系列 | 两个网关之间存在NAT设备时通过IKE方式协商IPSec VdPdNd隧道(总部通过NAT前的IP认证分支)
玩转华为ENSP模拟器系列 | 两个网关之间配置IPSec VdPdNd主备链路备份
玩转华为ENSP模拟器系列 | 两个网关之间通过手工方式创建IPSec VdPdNd隧道
玩转华为ENSP模拟器系列 | 两个网关之间通过IKE方式协商IPSec VdPdNd隧道(采用证书认证)