素材来源:华为防火墙配置指南
一边学习一边整理试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:玩转华为ENSP模拟器系列 | 合集_COCOgsta的博客-CSDN博客_华为模拟器实验
目标 介绍两个IP地址都固定的网关之间通过CLI方式建立证书认证方式的IPSec VPN隧道配置举例,两端PC都可以主动发起协商。
组网需求
如图1所示,网络A和网络B分别通过FW_A和FW_B连接到Internet。网络环境描述如下:
FW_A和FW_B采用RSA-Signature方式进行身份认证。在身份认证时,FW_A将自己的本地证书发送至FW_B,FW_B通过从CA中心获取到的CA证书来验证FW_A的本地证书,验证通过则表明FW_A的身份合法,从而FW_B允许与FW_A建立IPSec隧道。IPSec的身份验证机制是双向验证,FW_A也要验证FW_B的身份合法性,其过程与FW_B验证FW_A相同。
配置思路
操作步骤
配置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] destination-address 1.1.4.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] source-address 1.1.4.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和CA的静态路由,此处假设到达网络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] ip route- static 1.1.4.0 255.255.255.0 1.1.3.2
复制代码
使用SCEP协议为FW_A在线申请证书。
[FW_A] pki rsa local-key-pair create rsa_scep exportable
Info: The name of the new key-pair will be: rsa_scep
The size of the public key ranges from 512 to 2048.
Input the bits in the modules:2048
Generating key-pairs...
..................+++
.+++
复制代码
[FW_A] pki entity user01
[FW_A-pki-entity-user01] common-name devicea
[FW_A-pki-entity-user01] country cn
[FW_A-pki-entity-user01] email test@user. com
[FW_A-pki-entity-user01] fqdn test. abc . com
[FW_A-pki-entity-user01] ip-address 1.1.3.1
[FW_A-pki-entity-user01] state beijing
[FW_A-pki-entity-user01] organization huawei
[FW_A-pki-entity-user01] organization-unit dev
[FW_A-pki-entity-user01] quit
复制代码
[FW_A] pki realm abc
#.配置信任的CA。
[FW_A-pki-realm-abc] ca id ca_root
#.绑定的实体。
[FW_A-pki-realm-abc] entity user01
#.配置CA证书指纹,举例中假设为“6330974fb2fe3c52d16bdac40140918b4bcd3ec7”。
[FW_A-pki-realm-abc] fingerprint sha1 6330974fb2fe3c52d16bdac40140918b4bcd3ec7
#.配置注册证书的URL,指定从CA申请证书。
[FW_A-pki-realm-abc] enrollment-url http : //10.136.7.196:8080/certsrv/mscep/mscep.dll ra
# 指定申请证书使用的RSA密钥对。
[FW_A-pki-realm-abc] rsa local-key-pair rsa_scep
#.指定挑战密码,举例中假设挑战密码为“6AE73F21E6D3571D”。
[FW_A-pki-realm-abc] password cipher 6AE73F21E6D3571D
[FW_A-pki-realm-abc] quit
#.获取CA证书至本地。
[FW_A] pki get-certificate ca realm abc
复制代码
[FW_A] pki import -certificate ca filename abc_ca. cer
The CA's Subject is /CN=ca_root
The CA's fingerprint is:
MD5 fingerprint:1135 25D8 96D3 5936 C382 35EA 2CEE 80EB
SHA1 fingerprint:6330 974F B2FE 3C52 D16B DAC4 0140 918B 4BCD 3EC7
Is the fingerprint correct?(Y/N):y
Info: Succeeded in importing file.
复制代码
[FW_A] pki realm abc
[FW_A-pki-realm-abc] auto-enroll 60 regenerate 2048
[FW_A-pki-realm-abc] quit
复制代码
在FW_A上配置IPSec策略,并在接口上应用此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
复制代码
[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 rsa-signature
[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] local-id-type dn
[FW_A-ike-peer-b] remote-id-type dn
[FW_A-ike-peer-b] certificate local-filename abc_local. cer
[FW_A-ike-peer-b] remote-address 1.1.5.1
[FW_A-ike-peer-b] remote-id /C= CN / ST =beijing/O=huawei/ OU =dev/ CN =deviceb
[FW_A-ike-peer-b] quit
复制代码
[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
复制代码
[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地址。
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] destination-address 1.1.4.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] source-address 1.1.4.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和CA的静态路由,此处假设到达网络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] ip route- static 1.1.4.0 255.255.255.0 1.1.5.2
复制代码
使用SCEP协议为FW_B在线申请证书。
[FW_B] pki rsa local-key-pair create rsa_scep_b exportable
Info: The name of the new key-pair will be: rsa_scep_b
The size of the public key ranges from 512 to 2048.
Input the bits in the modules:2048
Generating key-pairs...
..................+++
.+++
复制代码
[FW_B] pki entity user02
[FW_B-pki-entity-user02] common-name deviceb
[FW_B-pki-entity-user02] country cn
[FW_B-pki-entity-user02] email test2@user. com
[FW_B-pki-entity-user02] fqdn test2. abc . com
[FW_B-pki-entity-user02] ip-address 1.1.5.1
[FW_B-pki-entity-user02] state beijing
[FW_B-pki-entity-user02] organization huawei
[FW_B-pki-entity-user02] organization-unit dev
[FW_B-pki-entity-user02] quit
复制代码
[FW_B] pki realm b
#.配置信任的CA。
[FW_B-pki-realm-b] ca id ca_root
#.绑定的实体。
[FW_B-pki-realm-b] entity user02
#.配置CA证书指纹,举例中假设为“6330974fb2fe3c52d16bdac40140918b4bcd3ec7”。
[FW_B-pki-realm-b] fingerprint sha1 6330974fb2fe3c52d16bdac40140918b4bcd3ec7
#.配置注册证书的URL,指定从CA申请证书。
[FW_B-pki-realm-b] enrollment-url http : //10.136.7.196:8080/certsrv/mscep/mscep.dll ra
# 指定申请证书使用的RSA密钥对。
[FW_B-pki-realm-b] rsa local-key-pair rsa_scep_b
#.指定挑战密码,举例中假设挑战密码为“6AE73F21E6D3571D”。
[FW_B-pki-realm-b] password cipher 6AE73F21E6D3571D
[FW_B-pki-realm-b] quit
#.获取CA证书至本地。
[FW_B] pki get-certificate ca realm b
复制代码
[FW_B] pki import -certificate ca filename b_ca. cer
The CA's Subject is /CN=ca_root
The CA's fingerprint is:
MD5 fingerprint:1135 25D8 96D3 5936 C382 35EA 2CEE 80EB
SHA1 fingerprint:6330 974F B2FE 3C52 D16B DAC4 0140 918B 4BCD 3EC7
Is the fingerprint correct?(Y/N):y
Info: Succeeded in importing file.
复制代码
[FW_B] pki realm b
[FW_B-pki-realm-b] auto-enroll 60 regenerate 2048
[FW_B-pki-realm-b] quit
复制代码
在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] quit
复制代码
[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 rsa-signature
[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] local-id-type dn
[FW_B-ike-peer-a] remote-id-type dn
[FW_B-ike-peer-a] certificate local-filename b_local. cer
[FW_B-ike-peer-a] remote-address 1.1.3.1
[FW_B-ike-peer-a] remote-id /C= CN / ST =beijing/O=huawei/ OU =dev/ CN =devicea
[FW_B-ike-peer-a] quit
复制代码
[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
复制代码
[FW_B] interface gigabitethernet 1 / 0 / 1
[FW_B-GigabitEthernet1/0/1] ipsec policy map1
[FW_B-GigabitEthernet1/0/1] quit
复制代码
结果验证
display ike sa
Ike sa information :
Conn-ID Peer VPN Flag(s) Phase
------------------------------------------------------------------------------
16782412 1.1.3.1 RD|A v2:2
16782411 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
display ipsec sa
ipsec sa information:
===============================
Interface: GigabitEthernet1/0/1
===============================
-----------------------------
IPsec policy name: "map1"
Sequence number : 10
Acl group : 3000
Acl rule : 5
Mode: :ISAKMP
-----------------------------
Connection ID : 16794025
Encapsulation mode: Tunnel
Tunnel local : 1.1.5.1
Tunnel remote : 1.1.3.1
Flow source : 10.1.2.0-10.1.2.255 0-65535 0
Flow destination : 10.1.1.0-10.1.1.255 0-65535 0
[Outbound ESP SAs]
SPI: 5365969 (0x51e0d1)
Proposal: ESP-ENCRYPT-AES-256 SHA2-256-128
SA remaining key duration (kilobytes/sec): 1843200/3587
Max sent sequence-number: 1
UDP encapsulation used for NAT traversal: N
SA encrypted packets (number/kilobytes): 4/0
[Inbound ESP SAs]
SPI: 7519344 (0x72bc70)
Proposal: ESP-ENCRYPT-AES-256 SHA2-256-128
SA remaining key duration (kilobytes/sec): 1843200/3587
Max received sequence-number: 1
UDP encapsulation used for NAT traversal: N
SA decrypted packets (number/kilobytes): 4/0
Anti-replay : Disable