GRE(General Routing Encapsulation ,通用路由封装)是对某些网络层协议(如IP和IPX)的数据报文进行封装,使这些被封装的报文能够在另一网络层协议(如IP)中传输。此外 GRE协议也可以作为VPN的第三层隧道协议连接两个不同的网络,为数据的传输提供一个透明的通道。

为了方便实验操作,建议在每台设备配置如下命令。关闭日志消息,会话超时设为120分钟。

system

undo info enable

user-int con 0

idle-timeout 120

quit

拓扑图

 

基本配置

R1

int g0/0/0
ip add 172.16.1.254 24
int g0/0/1
ip add 100.100.100.1 30
 

R2
int g0/0/0
ip address 192.168.1.254 24
int g0/0/2
ip add 200.200.200.1 30

R3

sys ISP
int g0/0/1
ip add 100.100.100.2 30
int g0/0/2
ip add 200.200.200.2 30

R1的缺省路由

ip route-static 0.0.0.0 0 100.100.100.2

R2的缺省路由

ip route-static 0.0.0.0 0 200.200.200.2

在办公上ping Server1发现ping不通

 使用GRE协议

在R1上配置隧道接口并启用

int Tunnel 0/0/1
ip add 1.1.1.1 30 
tunnel-protocol gre

建立源ip和目的ip隧道

source 100.100.100.1 
destination 200.200.200.1

配置明细路由

ip route-static 192.168.1.0 24 Tunnel 0/0/1

在R2上重复以上操作

int Tunnel 0/0/2
ip add 1.1.1.2 30
tunnel-protocol gre

source  200.200.200.1 
destination 100.100.100.1

ip route-static 172.16.1.0 24 Tunnel 0/0/2

再去ping192.168.1.1,可以ping通

Logo

欢迎加入 MCP 技术社区!与志同道合者携手前行,一同解锁 MCP 技术的无限可能!

更多推荐