肥仔教程网

SEO 优化与 Web 开发技术学习分享平台

【企业主优选】低成本实现异地内网互通!GRE+IPSec 组网省 30% 预算

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

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

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

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

点击右上角【关注】每日更新深度技术指南,

长按【收藏】 搭建你的专属运维知识库,

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

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

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

组网拓扑图

  • AR2(分支):公网地址 13.1.1.1,内网 192.168.6.0/24
  • AR3(总部):公网地址 23.1.1.2,内网 192.168.11.0/24
  • GRE隧道地址段: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]

GRE + IPSec 完整配置过程

第1步:GRE 隧道的建立

#AR1配置ip地址
int gi 0/0/0
  ip add 13.1.1.2 30
int 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 2000
int gi 0/0/1
  ip add 192.168.6.1 24 
acl 2000
  rule 5 permit source any
ip 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  2000
int gi 0/0/1
  ip add 192.168.10.1 24
int gi 0/0/2
  ip add 192.168.11.1 24
acl 2000
  rule 5 permit source  any
#配置静态路由     
ip route-static  0.0.0.0 0.0.0.0  23.1.1.1
ip 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接口up

IPSec不加密

检查ACL是否匹配,SPI配置是否一致

内网不通

检查静态路由指向 Tunnel 地址

有通但不稳定

建议改用 IPSec IKE协商模式

总结一句话:

GRE over IPSec 是连接异地内网的“黄金搭档”GRE 保通路,IPSec 保安全!

注意

  1. GRE 隧道地址必须能通!
  2. IPSec 的加密是针对 GRE 封装后的包!
  3. SPI、密钥一定要双方一致(手工模式)
  4. ACL 写的源目地址必须命中真实通信路径!

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

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

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

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

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言