GRE隧道

7 篇文章 2 订阅
7 篇文章 6 订阅

在这里插入图片描述

实验拓扑

在这里插入图片描述

实验要求

通过学习GRE隧道的原理和配置,从而掌握GRE隧道的特点和使用。

本次实验由三台路由器完成,其中R1和R3上存在环回接口,其IP地址分别为1.1.1.1和3.3.3.3并且R1和,R2和R3之间运行EIGRP路由协议,但是不将环回口加入EIGRP进程中。也就是说在R1上使用1.1.1.1去ping3.3.3.3无法通信。

实验配置

配置好R1,R2以及R3上的相关接口IP地址。并且配置好EIGRP路由协议。使得R1能够学习到10.10.23.0/24的路由,R3能够学习到10.10.12.0/2 的路由。查看R1和R3的路由表,如下:

R1:
R1#configure terminal 
R1(config)#interface e0/0
R1(config-if)#ip add 10.10.12.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int loo0 
R1(config-if)#ip add 1.1.1.1 255.255.255.0   
R1(config-if)#no sh
R1(config)#router eigrp 1
R1(config-router)#no au       
R1(config-router)#net 10.10.12.0

R2:
R2#configure terminal 
R2(config)#interface e0/1 
R2(config-if)#ip add 10.10.12.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int e0/0
R2(config-if)#ip add 10.10.23.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int loo0
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#no sh
R2(config)#router eigrp 1
R2(config-router)#no au 
R2(config-router)#net 10.10.12.0 
R2(config-router)#net 10.10.23.0 

R3;
R3#configure terminal 
R3(config)#int e0/1
R3(config-if)#ip add 10.10.23.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int loo0
R3(config-if)#ip add 3.3.3.3 255.255.255.0
R3(config-if)#no sh
R3(config)#router eigrp 1
R3(config-router)#no au
R3(config-router)#net 10.10.23.0 
  1. 现在,要求R1的1.1.1.1 和 R3的3.3.3.3 通过GRE隧道相互通信。则需要在R1和R3之间配置GRE隧道。
    GRE隧道(通过路由封装)协议能够封装多种协议的数据包,因此功能强大,能够将需要的内容封装进入不支持该内容的网络区域传递出去。
    并且GRE隧道为单向的,因此一条正确的GRE隧道是需要在起始端点上都需要配置的。

首先在R1上配置到R3d1GRE隧道。

R1:
R1(config)#int tunnel 13
R1(config-if)#
*Mar  1 00:39:23.227: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel13, changed state to up		//当隧道的源IP地址的目的IP地址之间能够相互通信的话,那么该隧道便能够up起来
R1(config-if)#tunnel source 10.10.12.1 //隧道IP源地址
R1(config-if)#tunnel mode gre ip	//隧道模式为GRE模式
R1(config-if)#ip add 10.10.13.1 255.255.255.0 //为隧道配置为一个IP地址,使得隧道两端逻辑上直连

>同样的在R3上也配置一条GRE隧道指向R1

R3:
R3(config)#int tunnel 13 
R3(config-if)#tunnel source 10.10.12.1 
R3(config-if)#tunnel destination 10.10.23.3 
R3(config-if)#
*Mar  1 00:41:46.247: %LINEPROTO-5-UPDOWN: Line protocol on Interface Tunnel13, changed state to up
R3(config-if)#tunnel mode gre ip
R3(config-if)#ip add 10.10.13.1 255.255.255.0

然后,我们在R1和R3上分别建立去往3.3.3.3和1.1.1.1上的静态路由。

R1(config)#ip route 3.3.3.0 255.255.255.0 tunnel 13

R3(config)#ip route 1.1.1.0 255.255.255.0 tunnel 13

最后验证,在R1上ping3.3.3.3,并且以1.1.1.1为源IP地址。

实验总结

在这里插入图片描述
那么总结本实验GRE隧道的实际操作步骤。当R1想要发给3.3.3.3地址数据包时,根据本地静态路由,该数据包将被发往隧道13中,而隧道13为GRE,因此原始的ICMP ping包被封装进入GRE包中,外层还有一层IP包头,其源IP地址为10.10.13.1,目的IP地址为10.10.13.3。这个数据包从R1的e0/0为源起发往R3的e0/1.当R3收到该GRE隧道包后,拆包,获取了内部原始ICMP ping 包,发给环回口3.3.3.3.这样就能够相互ping通了。

  • 60
    点赞
  • 62
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 49
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 49
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

牧鸯人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值