配置GRE-tunnel隧道(思科&华为)

配置GRE-tunnel隧道思科

配置示例: Route0是公网的路由 在Router1和Router2中使用默认路由指向Route0用来模拟公网透明传输

Router1:

复制代码
ip route 0.0.0.0 0.0.0.0 <R0的接口/直连ip地址>

Router2:

复制代码
ip route 0.0.0.0 0.0.0.0 <R0的接口/直连ip地址>

配置Router1和Router2之间的GRE隧道 隧道的源接口是 FastEthernet0/1,目标是Router2 的 FastEthernet0/1

Router1:

复制代码
 
复制代码
interface Tunnel0

给GRE隧道配置ip地址

复制代码
 ip address <R1隧道的ip地址> <子网掩码>

指定隧道的接口

复制代码
 
复制代码
tunnel source FastEthernet0/1

指定目的接口的ip地址

复制代码
 tunnel destination <R2的目的接口的ip地址>
 no shutdown

Router2:

复制代码
 
复制代码
interface Tunnel0

给GRE隧道配置ip地址

复制代码
 ip address <R2隧道的ip地址> <子网掩码>

指定隧道的接口

复制代码
 
复制代码
tunnel source FastEthernet0/1

指定目的接口的ip地址

复制代码
tunnel destination <R1的目的接口的ip地址>
no shutdown

在R1和R2中使用 ospf 路由(端到端路由传递) Router1: 配置进程号(仅本地有效)

复制代码
router ospf 1

指定路由器id号用于区分路由器

复制代码
router-id 1.1.1.1
network <与R1相连接的内网网段> <子网掩码/反掩码> area 0
network <隧道ip的网段> <子网掩码/反掩码> area 0

Router2: 配置进程号(仅本地有效)

复制代码
router ospf 1

指定路由器id号用于区分路由器

复制代码
xx
复制代码
router-id 2.2.2.2
network <与R2相连接的内网网段> <子网掩码/反掩码> area 0
network <隧道ip的网段> <子网掩码/反掩码> area 0

验证隧道接口的状态:

复制代码
show ip interface brief

应显示 up/up 状态 输出应显示静态路由条目,验证静态路由已成功配置:

复制代码
show ip route

查看邻居建立结果:

复制代码
show ip ospf interface

GRE隧道技术华为

拓扑图:

来配置公网路由部分 R1

复制代码
sys
sys AR1
int g0/0/0
ip add 172.16.1.2 24
int g0/0/1
ip add 172.16.2.2 24
quit
ospf 1
area 0
network 172.16.1.0 0.0.0.255
network 172.16.2.0 0.0.0.255
quit
quit

R2

复制代码
sys
sys AR2
int g0/0/0
ip add 172.16.1.1 24
int g0/0/2
ip add 192.168.1.254 24
quit
ospf 1
area 0
network 172.16.1.0 0.0.0.255
quit
quit

用于显示与OSPF(开放最短路径优先)协议相关的IP路由表信息

复制代码
display ip  routing-table protocol ospf

R3

复制代码
sys
sys AR3
int g0/0/1
ip add 172.16.2.1 24
int g0/0/2
ip add 192.168.2.254 24
quit
ospf 1
area 0
network 172.16.2.0 0.0.0.255
quit
quit

接下来配置内网路由和GRE隧道 R2

复制代码
int Tunnel 0/0/1
tunnel-protocol gre
ip add 10.1.1.1 24
source 172.16.1.1
destination 172.16.2.1
keepalive
quit
ospf 2
area 0
network 10.1.1.0 0.0.0.255
network 192.168.1.0 0.0.0.255
quit
quit

R3

复制代码
int Tunnel 0/0/1
tunnel-protocol gre
ip add 10.1.1.2 24
source 172.16.2.1
destination 172.16.1.1
keepalive
quit
ospf 2
area 0
network 10.1.1.0 0.0.0.255
network 192.168.2.0 0.0.0.255
quit
quit

本次实验通过GRE隧道技术实现了在不通过公网路由的情况下实现两个内网之间的相互通信

相关推荐
人工智能训练1 小时前
【极速部署】Ubuntu24.04+CUDA13.0 玩转 VLLM 0.15.0:预编译 Wheel 包 GPU 版安装全攻略
运维·前端·人工智能·python·ai编程·cuda·vllm
汤愈韬2 小时前
ACL概述、ACL原理、基本ACL应用及配置
网络·网络协议·网络安全
微露清风2 小时前
系统性学习Linux-第二讲-基础开发工具
linux·运维·学习
阳光九叶草LXGZXJ3 小时前
达梦数据库-学习-48-DmDrs控制台命令(同步之Manager、CPT模块)
linux·运维·数据库·sql·学习
小二李5 小时前
第11章 nestjs服务端开发:登录鉴权
运维·服务器
i建模5 小时前
如何在Arch Linux中重设忘记的root密码
linux·运维·服务器
chatexcel6 小时前
元空AI+Clawdbot:7×24 AI办公智能体新形态详解(长期上下文/自动化任务/工具粘合)
运维·人工智能·自动化
码刘的极客手记6 小时前
VCAP4-DCA Beta 考试体验分享与 esxcli 自动化实战(第二、三部分)
网络·esxi·vmware·虚拟机
kida_yuan6 小时前
【Linux】运维实战笔记 — 我常用的方法与命令
linux·运维·笔记
朝风工作室7 小时前
开源一款轻量级跨网段 IPC 设备发现与网络配置工具
网络·开源