小乔 发表于 2018-6-5 09:45:03

GRE tunnel介绍以及配置

本帖最后由 小乔 于 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)各接口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 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 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 via 10.10.10.1, 03:54:10, Tunnel2
S*   0.0.0.0/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隧道正常,此时异地之间如同处于一个局域网内且可以进行动态路由的更新。
**** Hidden Message *****

black105133 发表于 2018-6-5 10:35:37

{:6_268:}

346000064 发表于 2018-6-5 11:38:10

感谢感谢

jmyy_1 发表于 2018-7-13 18:33:21

xuexi

lsbin 发表于 2018-11-21 14:55:17

学习看看

iceyyf 发表于 2018-11-22 09:14:17

{:1_1:}

boyuxiao 发表于 2018-12-6 15:42:21

ddddddddddd

Frainbow 发表于 2018-12-6 17:03:47

6666666666

sirup1343456 发表于 2018-12-7 23:41:11

{:6_267:}

sirup1343456 发表于 2018-12-7 23:41:31

謝謝分享

sirup1343456 发表于 2018-12-7 23:41:46

{:6_267:}{:6_267:}

叶柏良 发表于 2018-12-14 17:48:28

:victory:感谢楼主~~

cqipconfig 发表于 2019-1-9 14:07:17

学习下GRE

tengshoujian 发表于 2019-1-14 10:53:15

谢谢分享

hobart_zj 发表于 2019-1-14 18:50:02

谢谢
页: [1] 2 3
查看完整版本: GRE tunnel介绍以及配置