素材来源:华为防火墙配置指南
一边学习一边整理试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:玩转华为ENSP模拟器系列 | 合集_COCOgsta的博客-CSDN博客_华为模拟器实验
目标
手工方式建立IPSec隧道需要手工配置安全协议,入方向和出方向的安全参数索引(SPI),以及安全协议采用的入方向和出方向的验证密钥。当与FW进行通信的对等体设备数量较少时,或是在小型静态环境中,手工配置安全联盟是可行的,但不推荐。
组网需求
如图1所示,网络A和网络B之间采用网关对网关组网模式进行资源传输。网络A和网络B分别通过FW_A和FW_B连接到Internet。网络环境描述如下:
- 网络A属于10.1.1.0/24子网,通过接口GE1/0/3与FW_A连接。
- 网络B属于10.1.2.0/24子网,通过接口GE1/0/3与FW_B连接。
- FW_A和FW_B路由可达。
配置思路
- 根据网络规划为FW分配接口,配置接口的IP地址并将接口加入相应的安全区域。
- 通过配置高级ACL规则组来定义需要保护的数据流。
- 配置域间安全策略。
- 配置IPSec安全提议。
- 配置IPSec策略。
- 应用IPSec策略。
操作步骤
配置FW_A。
- 配置接口IP地址。
- 配置接口GE1/0/3的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
复制代码
- 配置接口GE1/0/1的IP地址。
[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
复制代码
- 配置接口加入相应安全区域。
- 将接口GE1/0/3加入Trust区域。
[FW_A] firewall zone trust
[FW_A-zone-trust] add interface gigabitethernet 1 / 0 / 3
[FW_A-zone-trust] quit
复制代码
- 将接口GE1/0/1加入Untrust区域。
[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] 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.3.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.3.1 32
[FW_A-policy-security-rule-policy4] action permit
[FW_A-policy-security-rule-policy4] quit
[FW_A-policy-security] quit
复制代码
- 配置到达网络B的静态路由,此处假设到达网络B的下一跳地址为1.1.3.2。
[FW_A] ip route- static 10.1.2.0 255.255.255.0 1.1.3.2
[FW_A] ip route- static 1.1.5.0 255.255.255.0 1.1.3.2
复制代码
- 配置高级ACL 3000,允许10.1.1.0/24网段访问10.1.2.0/24网段。
[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] encapsulation-mode tunnel
[FW_A-ipsec-proposal-tran1] transform esp
[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
复制代码
- 配置名称为map1,序号为10的IPSec策略。
[FW_A] ipsec policy map1 10 manual
[FW_A-ipsec-policy-manual-map1-10] security acl 3000
[FW_A-ipsec-policy-manual-map1-10] proposal tran1
[FW_A-ipsec-policy-manual-map1-10] tunnel remote 1.1.5.1
[FW_A-ipsec-policy-manual-map1-10] tunnel local 1.1.3.1
[FW_A-ipsec-policy-manual-map1-10] sa spi inbound esp 12345678
[FW_A-ipsec-policy-manual-map1-10] sa spi outbound esp 87654321
[FW_A-ipsec-policy-manual-map1-10] sa string-key inbound esp abcdefg
[FW_A-ipsec-policy-manual-map1-10] sa string-key outbound esp gfedcba
[FW_A-ipsec-policy-manual-map1-10] quit
复制代码
- 在接口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地址。
- 配置接口GE1/0/3的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
复制代码
- 配置接口GE1/0/1的IP地址。
[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区域。
[FW_B] firewall zone trust
[FW_B-zone-trust] add interface gigabitethernet 1 / 0 / 3
[FW_B-zone-trust] quit
复制代码
- 将接口GE1/0/1加入Untrust区域。
[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
复制代码
- 配置到达目的网络A的静态路由,此处假设到达网络A的下一跳地址为1.1.5.2。
[FW_B] ip route- static 10.1.1.0 255.255.255.0 1.1.5.2
[FW_B] ip route- static 1.1.3.0 255.255.255.0 1.1.5.2
复制代码
- 配置高级ACL 3000,允许10.1.2.0/24网段访问10.1.1.0/24网段。
[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] quit
复制代码
- 配置名称为tran1的IPSec安全提议。
[FW_B] ipsec proposal tran1
[FW_B-ipsec-proposal-tran1] encapsulation-mode tunnel
[FW_B-ipsec-proposal-tran1] transform esp
[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
复制代码
- 配置名称为map1序号为10的IPSec策略。
[FW_B] ipsec policy map1 10 manual
[FW_B-ipsec-policy-manual-map1-10] security acl 3000
[FW_B-ipsec-policy-manual-map1-10] proposal tran1
[FW_B-ipsec-policy-manual-map1-10] tunnel remote 1.1.3.1
[FW_B-ipsec-policy-manual-map1-10] tunnel local 1.1.5.1
[FW_B-ipsec-policy-manual-map1-10] sa spi inbound esp 87654321
[FW_B-ipsec-policy-manual-map1-10] sa spi outbound esp 12345678
[FW_B-ipsec-policy-manual-map1-10] sa string-key inbound esp gfedcba
[FW_B-ipsec-policy-manual-map1-10] sa string-key outbound esp abcdefg
[FW_B-ipsec-policy-manual-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_A和FW_B上执行display ipsec sa会显示安全联盟的建立情况。以FW_B为例,出现以下显示信息说明IPSec安全联盟建立成功。
<FW_B> display ipsec sa
ipsec sa information:
===============================
Interface: GigabitEthernet1/0/1
===============================
-----------------------------
IPSec policy name: "map1"
Sequence number : 10
Acl group : 3000
Acl rule : -
Mode : Manual
-----------------------------
Encapsulation mode: Tunnel
Tunnel local : 1.1.5.1
Tunnel remote : 1.1.3.1
[Outbound ESP SAs]
SPI: 12345678 (0xbc614e)
Proposal: ESP-ENCRYPT-AES-256 SHA2-256-128
SA encrypted packets (number/bytes): 0/0
No duration limit for this SA
[Inbound ESP SAs]
SPI: 87654321 (0x5397fb1)
Proposal: ESP-ENCRYPT-AES-256 SHA2-256-128
SA decrypted packets (number/bytes): 0/0
No duration limit for this SA
Anti-replay : Disable
复制代码
网络A上执行ping操作可以ping通网络B,执行命令display ipsec statistics可以查看被加密的数据。例如:
<FW_B> display ipsec statistics
IPSec statistics information:
the security packet statistics:
input/output security packets: 20 / 20
input/output security bytes: 2000/2000
input/output dropped security packets: 0/0
the encrypt packet statistics:
send chip: 63, recv chip: 63, send err: 0
local cpu: 63, other cpu: 0, recv other cpu: 0
intact packet: 63, first slice: 0, after slice: 0
the decrypt packet statistics:
send chip: 244, recv chip: 244, send err: 0
local cpu: 244, other cpu: 0, recv other cpu: 0
reass first slice: 0, after slice: 0
dropped security packet detail:
can't find SA: 0, wrong SA: 0
authentication: 0, replay: 0
front recheck: 0, after recheck: 0
change cpu enc: 0, dec change cpu: 0
fib search: 0, output l3: 0
flow err: 0, slice err: 0, byte limit: 0
negotiate about packet statistics:
IKE fwd packet ok: 93, err: 0
IKE ctrl packet inbound ok: 92, outbound ok: 58
SoftExpr: 0, HardExpr: 0, DPDOper: 0
trigger ok: 0, switch sa: 35684, sync sa: 0
recv IKE nat keepalive: 114731, IKE input: 0