【实战拆解】分支如何安全连总部?用 GRE over IPSec 轻松搞定!

360影视 日韩动漫 2025-05-16 19:04 2

摘要:大家好,我是「极客运维社」飞哥!深耕企业组网和网络设备领域多年,每天为你拆解:1、交换机/路由器疑难故障处理方案2、网络架构优化与安全防护实战技巧3、中小企业低成本智能组网案例解析长按【收藏】 搭建你的专属运维知识库,点亮文末小红心,激励飞哥创作更多硬核内容。

大家好,我是「极客运维社」飞哥!深耕企业组网和网络设备领域多年,每天为你拆解:

1、交换机/路由器疑难故障处理方案

2、网络架构优化与安全防护实战技巧

3、中小企业低成本智能组网案例解析

点亮文末小红心,激励飞哥创作更多硬核内容。

特别提醒:网络运维问题常有突发性,建议将本文加入收藏,遇到设备配置、链路故障、卡顿、数据丢包等问题时,随时可调取解决方案!

很多企业都存在总部与多个分支机构间的内网通信需求,但公网环境下传递信息存在泄露风险,怎么办? 最经典的做法是用 GRE 建立逻辑隧道实现不同内网网段封装互通,再用 IPSec 对 GRE 封装的数据进行加密,双剑合璧——既实现穿透,又确保安全!

AR2(分支):公网地址 13.1.1.1,内网 192.168.6.0/24AR3(总部):公网地址 23.1.1.2,内网 192.168.11.0/24GRE隧道地址段:10.13.1.0/30 AR2 端: 10.13.1.1 AR3 端:10.13.1.2[PC1:192.168.6.2] ↓[AR2内网] → [Tunnel GRE封装] → [公网加密传输(IPSec)] → [AR3] → [PC2:192.168.11.2]

第1步:GRE 隧道的建立

#AR1配置ip地址int gi 0/0/0 ip add 13.1.1.2 30int gi 0/0/1 ip add 23.1.1.1 30#分公司AR2配置int gi 0/0/0 ip add 13.1.1.1 30 nat outbound 2000int gi 0/0/1 ip add 192.168.6.1 24 ACL 2000 rule 5 permit source anyip route-static 0.0.0.0 0.0.0.0 13.1.1.2 #配置静态路由ip route-static 192.168.0.0 255.255.0.0 Tunnel 0/0/3#AR2 配置GRE通道int tunnel 0/0/3 tunnel -protocol gre source 13.1.1.1 destination 23.1.1.2 ip add 10.13.1.1 30#总公司AR3路由器配置int gi 0/0/0 ip add 23.1.1.2 30 nat outbound 2000int gi 0/0/1 ip add 192.168.10.1 24int gi 0/0/2 ip add 192.168.11.1 24acl 2000 rule 5 permit source any#配置静态路由 ip route-static 0.0.0.0 0.0.0.0 23.1.1.1ip route-static 192.168.0.0 255.255.0.0 Tunnel 0/0/3#AR3 配置GRE通道int Tunnel 0/0/3 tunnel-protocol gre source 23.1.1.2 destination 13.1.1.1 ip add 10.13.1.2 30

第2步:配置 IPSec 手动模式加密 GRE 流量

# 分公司AR2配置acl num 3101 rule permit ip source 192.168.6.0 0.0.0.255 destination 192.168.11.0 0.0.0.255# 1)在分公司AR2路由上配置IPSEC安全提议ipsec proposal tran1 esp authentication-algorithm sha2-256 esp encryption-algorithm aes-128 q# 2)在分公司AR2路由上配置 手工方式安全策略ipsec policy use1 10 manual security acl 3101 proposal tran1 tunnel remote 23.1.1.2 tunnel local 13.1.1.1 sa spi outbound esp 54321 sa spi inbound esp 12345 sa string-key outbound esp cipher huawei123 sa string-key inbound esp cipher huawei123 q # 3)在分公司AR2路由的接口上引用安全策略组int gi 0/0/0 ipsec policy use1 q#总公司AR3配置acl num 3101 rule permit ip source 192.168.11.0 0.0.0.255 destination 192.168.6.0 0.0.0.255 q# 1)在总部路由上配置IPSEC安全提议ipsec proposal tran1 esp authentication-algorithm sha2-256 esp encryption-algorithm aes-128 q# 2)在总部路由上配置 手工方式安全策略ipsec policy map1 10 manual security acl 3101 proposal tran1 tunnel remote 13.1.1.1 tunnel local 23.1.1.2 sa spi outbound esp 12345 sa spi inbound esp 54321 sa string-key outbound esp cipher huawei123 sa string-key inbound esp cipher huawei123 q# 3)在总公司路由的接口上引用安全策略组int gi 0/0/0 ipsec policy map1 q

第3步 测试连通性

1、从分支测试总部主机连通性 [PC1] ping 192.168.11.2

2、查看GRE隧道状态 [AR2] display interface Tunnel 0/0/3

3、查看IPSec是否生效 [AR2] display ipsec sa

问题排查方法GRE隧道不通确保公网地址可达、Tunnel接口upIPSec不加密检查ACL是否匹配,SPI配置是否一致内网不通检查静态路由指向 Tunnel 地址有通但不稳定建议改用 IPSec IKE协商模式

如果你觉得这篇实战有帮助,记得点赞+收藏+关注我,后续我会继续分享:

• GRE over IPSec IKE协商模式配置(更自动、可扩展)

• 企业组网高可用方案(双出口、多链路、BFD检测)等相关视频。

需要这些内容?欢迎评论区见!

来源:极客运维社

相关推荐