设为首页收藏本站language 语言切换
查看: 3689|回复: 35
收起左侧

[分享] GRE tunnel介绍以及配置

[复制链接]
 成长值: 64540
发表于 2018-6-5 09:45:03 | 显示全部楼层 |阅读模式
本帖最后由 小乔 于 2018-11-21 12:59 编辑

tunnel:指保留原始IP数据流的情况下封装成另一种带有新IP报头(注:新IP为tunnel中的source、destination,这两个地址必须是UP状态的接口IP(包括虚接口),且两者能够通讯(包括路由可达、VPN等。VPN原始IP数据流协议为GRE时,两者ping不通,但也能够通讯的))的数据流,从而以新IP数据流路由转发出去;接收端通过tunnel解封装,得到原始IP的数据流。tunnel封装模式有多种,默认情况下指GRE模式。

GRE(Generic routing encapsulation)通用路由封装是一中隧道协议,能够在IP隧道中封装各种网络层协议的分组,从而创建虚拟点到点链路。GRE隧道并不提供加密服务,默认情况下以明文方式离开,所以通常使用GRE通过IPsec vpn隧道传输动态路由协议数据流。


tunnel(GRE隧道)与IPsec VPN隧道异同:

1、两者都可以保留原始IP数据流情况下进行封装,并异地传输。

2、tunnel在异地的两端建立虚拟隧道接口,相当于异地是直连关系(可以建立邻居关系),从而能传输动态协议等数据流,tunnel数据流以明文方式传输;IPsec VPN隧道没有虚接口,只传输单播而不能传输多播和广播,从而使众多路由协议无法建立邻居关系和传输路由更新,由于VPN封装是加密的,所以数据流以密文方式传输。

3、两者可以独立使用不相影响。但通常将两者组合使用,达到支持所有数据传输格式与安全,即tunnel被封装进IPSec VPN中。

1.jpg


实验配置:

1)各接口IP配置如上图,并在R3、R2上配置GRE隧道。

R3#sh run

interface Tunnel3
ip address 10.10.10.1 255.255.255.0   \\虚接口地址,和对端虚接口地址在同一网段
tunnel source 3.3.3.10   \\本地物理端口IP
tunnel destination 2.2.2.10   \\对端物理端口IP,作为GRE封装后新的IP报头。
!
interface FastEthernet0/0
ip address 3.3.3.10 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.1.1 255.255.255.0
speed auto
full-duplex
!
router eigrp 100
network 10.10.10.0 0.0.0.255
network 192.168.1.0
no auto-summary
!
ip route 0.0.0.0 0.0.0.0 3.3.3.3

R3#



R2#sh run

interface Tunnel2             \\与上面的R3的tunnel3对应。
ip address 10.10.10.2 255.255.255.0
tunnel source 2.2.2.10
tunnel destination 3.3.3.10
!
interface FastEthernet0/0
ip address 2.2.2.10 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 172.16.1.1 255.255.255.0
duplex auto
speed auto
!
router eigrp 100
network 10.10.10.0 0.0.0.255
network 172.16.1.0 0.0.0.255
no auto-summary
!
ip route 0.0.0.0 0.0.0.0 2.2.2.1

R2#

1.1)查看路由

R3(config)#do sh ip rou
Gateway of last resort is 3.3.3.3 to network 0.0.0.0
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, FastEthernet0/0
     172.16.0.0/24 is subnetted, 1 subnets
D       172.16.1.0 [90/297270016] via 10.10.10.2, 03:50:38, Tunnel3         \\目标地址的出口为tunnel3
     10.0.0.0/24 is subnetted, 1 subnets
C       10.10.10.0 is directly connected,Tunnel3     \\目标地址的出口为tunnel3
C    192.168.1.0/24 is directly connected, FastEthernet0/1
S*   0.0.0.0/0 [1/0] via 3.3.3.3
R3(config)#

R2#sh ip rou
Gateway of last resort is 2.2.2.1 to network 0.0.0.0
     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, FastEthernet0/0
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, FastEthernet0/1
     10.0.0.0/24 is subnetted, 1 subnets
C       10.10.10.0 is directly connected, Tunnel2
D    192.168.1.0/24 [90/297270016] via 10.10.10.1, 03:54:10, Tunnel2
S*   0.0.0.0/0 [1/0] via 2.2.2.1
R2#     

1.2)检测连通性及路由跟踪

R3#ping 172.16.1.2 sou 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 68/90/100 ms
R3#

R3#trace 172.16.1.2 sou 192.168.1.1
Type escape sequence to abort.
Tracing the route to 172.16.1.2
  1 10.10.10.2 84 msec 96 msec 60 msec
  2 172.16.1.2 96 msec 92 msec 76 msec

R3#

R3#trace 172.16.1.1 sou 192.168.1.1

Type escape sequence to abort.
Tracing the route to 172.16.1.1
  1 10.10.10.2 92 msec 56 msec 72 msec
R3#

已通表明GRE隧道正常,此时异地之间如同处于一个局域网内且可以进行动态路由的更新。
游客,如果您要查看本帖隐藏内容请回复

发表于 2018-12-6 15:42:21 | 显示全部楼层
ddddddddddd
7# 2018-12-6 15:42:21 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2018-12-6 17:03:47 | 显示全部楼层
6666666666
8# 2018-12-6 17:03:47 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-4-19 18:03 , Processed in 0.475533 second(s), 24 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表