素材来源:华为防火墙配置指南
一边学习一边整理试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:玩转华为ENSP模拟器系列 | 合集_COCOgsta的博客-CSDN博客_华为模拟器实验
目标
本例介绍总部的出口网关同时为NAT设备,总部和分支机构都通过总部网关上网时如何建立IPSec隧道。
组网需求
如图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地址。
- FW_A为NAT网关。
要求实现如下组网需求:
- 分支机构PC2、PC3能与总部PC1之间进行安全通信。
- FW_A、FW_B以及FW_A、FW_C之间分别建立IPSec隧道。FW_B、FW_C不直接建立任何IPSec连接。
- PC1可以直接访问公网,PC2和PC3通过总部网关访问公网。
配置思路
- 完成FW_A、FW_B和FW_C的接口、安全策略、路由等基本配置。
- 在FW_A、FW_B和FW_C上完成IPSec的配置。
- 在FW_A上完成源NAT的配置。总部和分支机构访问Internet的数据流都要经过NAT转换,而经过IPSec隧道的数据流不需要经过NAT转换,故要在NAT配置中进行区分。
操作步骤
-
配置FW_A的基础配置。
- 配置接口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策略。
-
定义被保护的数据流。
- 配置高级ACL 3000,定义总部到网络B的数据流。
-
[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.1.0 0.0.0.255 destination 10.1.3.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] pre-shared-key Test ! 1234 [FW_A-ike-peer-c] quit 复制代码
-
配置IPSec策略模板temp。
-
[FW_A] ipsec policy-template temp 1 [FW_A-ipsec-policy-templet-temp-1] security acl 3000 [FW_A-ipsec-policy-templet-temp-1] proposal tran1 [FW_A-ipsec-policy-templet-temp-1] ike-peer c [FW_A-ipsec-policy-templet-temp-1] quit 复制代码
-
创建IPSec策略map1,在安全策略中引用安全策略模板temp。
-
[FW_A] ipsec policy map1 10 isakmp template 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_A上配置NAT。
[FW_A] nat-policy
[FW_A-policy-nat] rule name policy_nat1
[FW_A-policy-nat-rule-policy_nat1] source-zone trust
[FW_A-policy-nat-rule-policy_nat1] destination-zone untrust
[FW_A-policy-nat-rule-policy_nat1] source-address 10.1.1.0 24
[FW_A-policy-nat-rule-policy_nat1] destination-address 10.1.2.0 24
[FW_A-policy-nat-rule-policy_nat1] destination-address 10.1.3.0 24
[FW_A-policy-nat-rule-policy_nat1] action no-nat
[FW_A-policy-nat-rule-policy_nat1] quit
[FW_A-policy-nat] rule name policy_nat2
[FW_A-policy-nat-rule-policy_nat2] source-zone trust
[FW_A-policy-nat-rule-policy_nat2] destination-zone untrust
[FW_A-policy-nat-rule-policy_nat2] source-address 10.1.1.0 24
[FW_A-policy-nat-rule-policy_nat2] action nat easy-ip
[FW_A-policy-nat-rule-policy_nat2] quit
[FW_A-policy-nat] quit
复制代码
-
配置FW_B的基础配置。
-
配置接口IP地址,并将接口加入域。 请根据图1的数据配置接口IP地址。 将接口GE1/0/3加入Trust区域,接口GE1/0/1加入Untrust区域。 详细步骤可参见FW_A的配置。
-
配置域间安全策略。
- 配置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] destination-address 10.1.3.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] source-address 10.1.3.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 复制代码
-
配置达到总部和其他分支机构的静态路由。
-
[FW_B] ip route- static 10.1.0.0 255.255.0.0 GigabiteEthernet 1 / 0 / 1 复制代码
-
-
在FW_B上配置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] quit 复制代码
- 配置IPSec安全提议tran1。采用默认参数。
-
[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 复制代码
- 配置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 复制代码
- 配置IPSec策略map1。
-
[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。 详细配置请参见FW_B。
结果验证
- 配置完成后,PC1在任何时候都可以访问公网,可以ping通FW_B的1.1.5.1,同时在FW_A上可以查看NAT转换session表项。
<FW_A> display firewall session table
Current Total Sessions : 5
icmp VPN:public --> public 10.1.1.2:61251[1.1.3.1:2048]-->1.1.5.1:2048
icmp VPN:public --> public 10.1.1.2:62019[1.1.3.1:2049]-->1.1.5.1:2048
icmp VPN:public --> public 10.1.1.2:62275[1.1.3.1:2050]-->1.1.5.1:2048
icmp VPN:public --> public 10.1.1.2:62531[1.1.3.1:2051]-->1.1.5.1:2048
icmp VPN:public --> public 10.1.1.2:62787[1.1.3.1:2052]-->1.1.5.1:2048
复制代码
- PC2在任何时候可以访问到公网,可以ping通公网的IP地址(假设为1.1.6.1),同时在FW_A上可以查看NAT转换session表项。
<FW_A> display firewall session table
Current Total Sessions : 5
icmp VPN:public --> public 10.1.2.2:61251[1.1.3.1:2053]-->1.1.6.1:2048
icmp VPN:public --> public 10.1.2.2:62019[1.1.3.1:2054]-->1.1.6.1:2048
icmp VPN:public --> public 10.1.2.2:62275[1.1.3.1:2055]-->1.1.6.1:2048
icmp VPN:public --> public 10.1.2.2:62531[1.1.3.1:2056]-->1.1.6.1:2048
icmp VPN:public --> public 10.1.2.2:62787[1.1.3.1:2057]-->1.1.6.1:2048
复制代码
- PC2发起访问,之后PC1与PC2之间可以相互访问。
- 总部防火墙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_B可以查看到对端为总部的IKE SA,FW_B是发起方,标志位为ST。
<FW_B> display ike sa
Ike sa information :
Conn-ID Peer VPN Flag(s) Phase
---------------------------------------------------------------
62887864 1.1.3.1 RD|A v2:2
62887652 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_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.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
复制代码
- 分支节点FW_B上可以查看到一对双向IPSec SA。
<FW_B> 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.3.1 1.1.5.1 787858613 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