素材来源:华为防火墙配置指南
一边学习一边整理试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:玩转华为ENSP模拟器系列 | 合集_COCOgsta的博客-CSDN博客_华为模拟器实验
目标
介绍两个IP地址都固定的网关之间建立通过CLI方式建立IPSec VPN隧道配置举例,两端PC都可以主动发起协商。
组网需求
如图1所示,网络A和网络B分别通过FW_A和FW_B连接到Internet。网络环境描述如下:
通过组网实现如下需求:在FW_A和FW_B之间建立基于路由的IPSec隧道,使网络A和网络B的用户可通过IPSec隧道互相访问。
配置思路
操作步骤
配置FW_A的基础配置。包括配置接口IP地址、接口加入安全区域、域间安全策略和静态路由。
配置接口IP地址。
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
复制代码
配置域间安全策略。
[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
复制代码
[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
复制代码
在FW_A上配置IPSec。
[FW_A] interface Tunnel 1
[FW_A-Tunnel1] tunnel-protocol ipsec
[FW_A-Tunnel1] source 1.1.3.1
[FW_A-Tunnel1] destination 1.1.5.1
[FW_A-Tunnel1] ip address 172.16.2.1 24
[FW_A-Tunnel1] quit
[FW_A] firewall zone untrust
[FW_A-zone-untrust] add interface tunnel 1
[FW_A-zone-untrust] quit
复制代码
[FW_A] ip route- static 10.1.2.0 24 Tunnel1
复制代码
[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
复制代码
[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
复制代码
[FW_A] ike peer b
[FW_A-ike-peer-b] ike-proposal 10
[FW_A-ike-peer-b] pre-shared-key Test ! 1234
[FW_A-ike-peer-b] quit
复制代码
[FW_A] ipsec profile pro1
[FW_A-ipsec-profile-pro1] proposal tran1
[FW_A-ipsec-profile-pro1] ike-peer b
[FW_A-ipsec-profile-pro1] quit
复制代码
[FW_A] interface tunnel 1
[FW_A-Tunnel1] ipsec profile pro1
[FW_A-Tunnel1] quit
复制代码
配置FW_B的基础配置。包括配置接口IP地址、接口加入安全区域、域间安全策略和静态路由。
配置接口IP地址。
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
复制代码
配置接口加入相应安全区域。
[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
复制代码
配置域间安全策略。
[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
复制代码
[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
复制代码
在FW_B上配置IPSec。
[FW_B] interface Tunnel 1
[FW_B-Tunnel1] tunnel-protocol ipsec
[FW_B-Tunnel1] source 1.1.5.1
[FW_B-Tunnel1] destination 1.1.3.1
[FW_B-Tunnel1] ip address 172.16.2.2 24
[FW_B-Tunnel1] quit
[FW_B] firewall zone untrust
[FW_B-zone-untrust] add interface tunnel 1
[FW_B-zone-untrust] quit
复制代码
[FW_B] ip route- static 10.1.1.0 24 Tunnel1
复制代码
[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
复制代码
[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
复制代码
[FW_B] ike peer a
[FW_B-ike-peer-a] ike-proposal 10
[FW_B-ike-peer-a] pre-shared-key Test ! 1234
[FW_B-ike-peer-a] quit
复制代码
[FW_B] ipsec profile pro1
[FW_B-ipsec-profile-pro1] proposal tran1
[FW_B-ipsec-profile-pro1] ike-peer a
[FW_B-ipsec-profile-pro1] quit
复制代码
[FW_B] interface tunnel 1
[FW_B-Tunnel1] ipsec profile pro1
[FW_B-Tunnel1] quit
复制代码
结果验证
display ike sa
Ike sa information :
Conn-ID Peer VPN Flag(s) Phase
------------------------------------------------------------------------------
16782310 1.1.3.1 RD|ST|A v2:2
16782309 1.1.3.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
display ipsec sa
ipsec sa information:
===============================
Interface: Tunnel1
===============================
-----------------------------
IPSec profile name: "pro1"
Mode : PROF-ISAKMP
-----------------------------
Connection ID : 16782310
Encapsulation mode: Tunnel
Tunnel local : 1.1.5.1
Tunnel remote : 1.1.3.1
[Outbound ESP SAs]
SPI: 3174037361 (0xbd2ff771)
Proposal: ESP-ENCRYPT-AES-256 SHA2-256-128
SA remaining key duration (kilobytes/sec): 20971520/3551
Max sent sequence-number: 1
UDP encapsulation used for NAT traversal: N
SA encrypted packets (number/bytes): 0/0
[Inbound ESP SAs]
SPI: 867840252 (0x33ba30fc)
Proposal: ESP-ENCRYPT-AES-256 SHA2-256-128
SA remaining key duration (kilobytes/sec): 20971520/3551
Max received sequence-number: 1
UDP encapsulation used for NAT traversal: N
SA decrypted packets (number/bytes): 0/0
Anti-replay : Disable