适配
适用于华为所有版本、所有形态的路由器
需求目的
- RouterA为企业分支网关,RouterB为企业总部网关,分支与总部通过公网建立通信。
- 分支子网为10.1.1.0/24,总部子网为10.1.2.0/24。
- 企业希望对分支子网与总部子网之间相互访问的流量进行安全保护。
- 分支与总部通过公网建立通信,可以在分支网关与总部网关之间建立一个IPSec隧道来实施安全保护。
- 由于维护网关较少,可以考虑采用手工方式建立IPSec隧道。
操作步骤
- 分支网关AR1配置
#
system
#
undo in en
#
sysname RA
#
acl number 3001 //配置扩展ACL(3000-3999任意)
rule 5 permit ip source 10.1.1.0 0.0.0.255 destination 10.1.2.0 0.0.0.255 //匹配从分支子网到总部子网的流量 permit 允许 any 禁止
#
ipsec proposal tran1 //设置ipsec提议,名字叫tran1
esp authentication-algorithm sha2-256 //设置ESP认证算法模式SHA-256
esp encryption-algorithm aes-128 //指定ESP的加密算法模式AES-128
#
ipsec policy cyly 10 manual //配置IPsec策略,名字叫cyly,优先级10,设置手动模式
security acl 3001 //使用指定的ACL
proposal tran1 //指定提议
tunnel local 1.1.1.1 //设置本地隧道IP地址
tunnel remote 2.1.1.1 //设置远程隧道IP地址
sa spi inbound esp 54321 //配置入方向的SA 使用SPI值为54321
sa string-key inbound esp cipher %$%$kerE(q-se7BvE0Hy>c!=,.2n%$%$ //设置SA配置的 加密密钥(注意,这里我写的明文密码是Huawei@123,自己根据需求定义,你按照正常的密码输入即可,使用命令: d th 他就会转换成密文)
sa spi outbound esp 12345 //配置出方向的SA 使用SPI值为12345
sa string-key outbound esp cipher %$%$kerE(q-se7BvE0Hy>c!=,.2n%$%$ //设置SA配置的 加密密钥(注意,这里我写的明文密码是Huawei@123,自己根据需求定义,你按照正常的密码输入即可,使用命令: d th 他就会转换成密文)
#
interface GigabitEthernet0/0/0
ip address 1.1.1.1 255.255.255.0
ipsec policy cyly //策略调用到接口
#
interface GigabitEthernet0/0/1
ip address 10.1.1.1 255.255.255.0
#
ip route-static 2.1.1.0 255.255.255.0 1.1.1.2 //配置一条目的地址是总部外网出口的静态路由
ip route-static 10.1.2.0 255.255.255.0 1.1.1.2 //配置一条目的地址是总部内网的静态路由
#
- 总部网关AR2配置
配置和RA1一样,只是改变一下方向
#
system
#
undo in en
#
sysname RB
#
acl number 3001 //配置扩展ACL(3000-3999任意)
rule 5 permit ip source 10.1.2.0 0.0.0.255 destination 10.1.1.0 0.0.0.255 //匹配从分支子网到总部子网的流量 permit 允许 any 禁止
#
ipsec proposal tran1 //设置ipsec提议,名字叫tran1
esp authentication-algorithm sha2-256 //设置ESP认证算法模式SHA-256
esp encryption-algorithm aes-128 //指定ESP的加密算法模式AES-128
#
ipsec policy use 10 manual
security acl 3001
proposal tran1
tunnel local 2.1.1.1
tunnel remote 1.1.1.1
sa spi inbound esp 12345
sa string-key inbound esp cipher %$%$kerE(q-se7BvE0Hy>c!=,.2n%$%$
sa spi outbound esp 54321
sa string-key outbound esp cipher %$%$kerE(q-se7BvE0Hy>c!=,.2n%$%$
#
interface GigabitEthernet0/0/0
ip address 2.1.1.1 255.255.255.0
ipsec policy use
#
interface GigabitEthernet0/0/1
ip address 10.1.2.1 255.255.255.0
#
ip route-static 1.1.1.0 255.255.255.0 2.1.1.2
ip route-static 10.1.1.0 255.255.255.0 2.1.1.2
#
- 验证
dis ipsec sa