26
2019
03
11:22:02

GRE隧道简单原理和实验



推荐点击下面图片,通过本站淘宝优惠价购买:

image.png

GRE隧道简单原理和实验

 一种技术(协议)或者策略的两个或多个子网穿过另一种技术(协议)或者策略的网络实现互联,称之为overlay topology,这一技术是电信技术的永恒主题之一。
 电信技术在发展,多种网络技术并存,一种技术的网络孤岛可能需要穿过另一种技术的网络实现互联,这种情况如果发生在高层协议的PDU封装于低层协议PDU中时通常称之为复用,特别地三层PDU穿过二层网络地技术称为租用链路或虚电路;而如果穿越发生在一种协议PDU封装在同一层协议的PDU中,或者封装在高层协议的PDU中时,人们通常称之为隧道。
 隧道提供了一种某一特定网络技术的PDU穿过不具备该技术转发能力的网络的手段,如组播数据包穿过不支持组播的网络;另一种情况是有时因为管理策略的原因,一个管理者(策略)的子网不能通过和另一个管理者(策略)的网络互联而连接,而是要穿过另一个管理者(策略)的网络实现连接,这就是所谓的***Virtual Private Networks),不管是L2 ***还是L3 ***都需要利用隧道技术实现。因此隧道某种意义上可以概括为穿越不同的网络的技术,不同既可以是技术方面的,也可以是管理策略方面的。
隧道可以作为一个虚拟接口来实现。隧道接口并不指定特定的乘客传输协议连接,而是一种结构,可以实现任何标准点到点封装的服务。由于隧道是点到点连接,因此对每个连接必须配置一个单独的隧道。
 GRE是一种应用较为广泛的一种网络层协议PDU封装于任一种网络层协议PDU中的技术,经常被用来构造GRE隧道穿越各种三层网络,并得到了大多数电信设备厂商的支持。


 GRE(通用路由协议封装)是由CiscoNet-smiths等公司于1994年提交给IETF的,标号为RFC1701RFC1702。目前有多数厂商的网络设备均支持GRE隧道协议。GRE 规定了如何用一种网络协议去封装另一种网络协议的方法。GRE的隧道由两端的源IP地址和目的IP地址来定义,允许用户使用IP包封装IPIPX、 AppleTalk包,并支持全部的路由协议(如RIP2OSPF等)。通过GRE,用户可以利用公共IP网络连接IPX网络、AppleTalk网 络,还可以使用保留地址进行网络互连,或者对公网隐藏企业网的IP地址。

 

 

 

 

 

 

1-1

一步骤:

先将4PC IP地址配好

R1

 r1#show run | in add

 ip address 1.1.1.1 255.255.255.255

 ip address 1.1.1.2 255.255.255.255

 ip address 1.1.1.3 255.255.255.255

 ip address 192.168.1.1 255.255.255.0

 ip address 12.12.12.1 255.255.255.0


R2

r2#show running-config | include add

 ip address 12.12.12.2 255.255.255.0

 ip address 23.23.23.2 255.255.255.0


R3

r2#show running-config | include add

 ip address 23.23.23.3 255.255.255.0

 ip address 34.34.34.3 255.255.255.0

 

R4

r4#sho running-config | in add

 ip address 2.2.2.1 255.255.255.255

 ip address 2.2.2.2 255.255.255.255

 ip address 2.2.2.3 255.255.255.255

 ip address 192.168.1.2 255.255.255.0

 ip address 34.34.34.4 255.255.255.0


配置好IP地址后可以检查下基本的连通性,用ping命令实现

r1#ping 12.12.12.2


Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 12.12.12.2, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 4/6/8 ms


Ip地址配置好后,先为隧道打好路由基础,为R2R3配置EIGRP,保证中间链路的完整性。

R2

r2#show running-config | be eigrp   

router eigrp 10

 network 12.12.12.2 0.0.0.0

 network 23.23.23.2 0.0.0.0

 no auto-summary


R3

R3#show running-config | be eigrp   

router eigrp 10

 network 23.23.23.3 0.0.0.0

 network 34.34.34.3 0.0.0.0

 no auto-summary


保证GRE隧道畅通后,配置两点间的隧道tunnel

R1:

interface Tunnel0

 ip address 192.168.1.1 255.255.255.0

 tunnel source 12.12.12.1

 tunnel destination 34.34.34.4

要保证tunnel 目的地址的可达性,所以写了条默认路由

R1(config)#ip route 0.0.0.0 0.0.0.0 ethernet 0/0


同理在r4

R4:

interface Tunnel0

 ip address 192.168.1.2 255.255.255.0

 tunnel source 34.34.34.4

 tunnel destination 12.12.12.1

R1(config)#ip route 0.0.0.0 0.0.0.0 ethernet 0/0


R1R4启动路由协议ospf

R1

r4#show run | be ospf

router ospf 10

 router-id 1.1.1.1

 log-adjacency-changes

 network 1.1.1.1 0.0.0.0 area 0

 network 1.1.1.2 0.0.0.0 area 0

 network 1.1.1.3 0.0.0.0 area 0

 network 192.168.1.1 0.0.0.0 area 0


R4

r4#show run | be ospf

router ospf 10

 router-id 2.2.2.2

 log-adjacency-changes

 redistribute connected subnets route-map oe

 redistribute static route-map oe

 network 2.2.2.2 0.0.0.0 area 1

 network 2.2.2.3 0.0.0.0 area 1

 network 192.168.1.2 0.0.0.0 area 0

!

Access-list1 permit host 2.2.2.1 

测试R1 R4路由表



R1

r1#show ip route 

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

       * - candidate default, U - per-user static route, o - ODR

       P - periodic downloaded static route


Gateway of last resort is 0.0.0.0 to network 0.0.0.0


     1.0.0.0/32 is subnetted, 3 subnets

C       1.1.1.1 is directly connected, Loopback0

C       1.1.1.3 is directly connected, Loopback3

C       1.1.1.2 is directly connected, Loopback1

     2.0.0.0/32 is subnetted, 3 subnets

O IA    2.2.2.2 [110/11112] via 192.168.1.2, 00:26:06, Tunnel0 由于宣告时使用的area1 所以属于3SLA 所以产生OIA

O IA    2.2.2.3 [110/11112] via 192.168.1.2, 00:26:06, Tunnel0

O E2    2.2.2.1 [110/20] via 192.168.1.2, 00:00:00, Tunnel0     12.0.0.0/24 is subnetted, 1 subnets  经过route-map 重分布直连 后学习到的路由 

C       12.12.12.0 is directly connected, Ethernet0/0

C    192.168.1.0/24 is directly connected, Tunnel0

S*   0.0.0.0/0 is directly connected, Ethernet0/0


R4

r4#show ip route 

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

       * - candidate default, U - per-user static route, o - ODR

       P - periodic downloaded static route


Gateway of last resort is 0.0.0.0 to network 0.0.0.0


     34.0.0.0/24 is subnetted, 1 subnets

C       34.34.34.0 is directly connected, Ethernet0/0

     1.0.0.0/32 is subnetted, 3 subnets

O       1.1.1.1 [110/11112] via 192.168.1.1, 00:27:48, Tunnel0

O       1.1.1.3 [110/11112] via 192.168.1.1, 00:27:48, Tunnel0

O       1.1.1.2 [110/11112] via 192.168.1.1, 00:27:48, Tunnel0

     2.0.0.0/32 is subnetted, 3 subnets

C       2.2.2.2 is directly connected, Loopback1

C       2.2.2.3 is directly connected, Loopback2

C       2.2.2.1 is directly connected, Loopback0

C    192.168.1.0/24 is directly connected, Tunnel0

S*   0.0.0.0/0 is directly connected, Ethernet0/0


本文链接:https://hqyman.cn/post/435.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:





休息一下,本站随机推荐观看栏目:


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

您的IP地址是: