已经快两个月的没写博客。一是年终工作繁琐,二是自己没有合理规划时间,一直没时间写博客,在此对支持和关注的我博客的博友和网友表示歉意。

新年第一篇博文,稍有点紧张。太久没什写博客,在组织言语方面或许比以前有所退步,写不好还请各位批评指正。闲话不多说,开始实验。

GRE :通用路由封装 , 全称 Generic Routing Encapsulation ,也算是×××技术的一种。它能快速、简单地跨越Internet(公网)实现私网之间连通,特别是在跨越公网组建大的网络。但GRE致命的缺点就是,他是明文传输数据。所以在部署GRE的时候,往往结合各种安全措施来保护数据,如利用Ipsec对其数加密。本文介绍GRE的一些简单的实验。

GRE 的原理并不复杂,它只是在私网IP包头前再封装一个公网的IP包头,而在公网上传输,公网的路由器看的只是公网的IP包头的IP,不会看到私网的IP包头,直到到达目标路由器,目标路由器接受到数据后,去除公网IP包头发现是GRE数据,那么它就将原封不动这个私网IP数据传送到内网中(只是IP包头以上的数据不动,改变的是二层报头)。我们也可以通俗的理解GRE,GRE跟大多数×××一样让整个Internet和部署GRE的路由器变成了一个路由器,那么两边或多边的网络就像是直接连接在一个路由器上,私网的IP就像普通在一个路由器上传输。

首先,看看本次实验的网络拓扑:



grep切分 grep cut_grep切分



IP 规划表:

Internet ß à zongbu

Internet 30.1.1.1/24        zongbu 30.1.1.2/24

Internet ß à fenbu_2

Internet <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />20.1.1.1/24        fenbu_2 20.1.1.2/24

Internet ß à fenbu_1

Internet 10.1.1.1/24        fenbu_1 10.1.1.2/24

zongbu ß à Server

zongbu 192.168.3.254/24     server 192.168.3.1/24

fenbu_2 ß à PC1

zongbu 192.168.2.254/24     PC1     192.168.2.1/24

fenbu_1 ß à PC0

zongbu 192.168.2.254/24     PC0     192.168.2.1/24

 

实验说明:

Internet 网还是用一个没有私网IP路由器表的路由器代替。基本连通配置见附件的基本连通PKT文件。本次验演示静态路由和GRE,动态路由和GRE。下面给出GRE的关键代码。

静态路由和GRE:

Zongbu 上路由器配置如下:

interface Tunnel0   (创建Tunnel接口0,此接口在本实验中是与fenbu_1建立GRE)

( 设置Tunnel 0的IP,此IP与fenbu_1同一网段)

 tunnel source FastEthernet0/0  (GRE封装时公网源IP为fa 0/0的IP)

 tunnel destination 10.1.1.2    (GRE封装是公网目标IP为 10.1.1.2的IP)

 

interface Tunnel1   (创建Tunnel接口1,此接口在本实验中是与fenbu_2建立GRE)

( 设置Tunnel 1的IP,此IP与fenbu_2同一网段)

 tunnel source FastEthernet0/0  (GRE封装时公网源IP为fa 0/0的IP)

 tunnel destination 20.1.1.2    (GRE封装时公网目标IP为 20.1.1.2的IP)

 

ip route 192.168.1.0 255.255.255.0 1.1.1.2 (配置通过GRE到达192.168.1.0/24的静态路由)

ip route 192.168.2.0 255.255.255.0 2.1.1.2 (配置通过GRE到达192.168.2.0/24的静态路由)

 

注:fenbu_1、fenbu_2只列出配置,不再进行说明。

fenbu_1 路由器的配置:

interface Tunnel0

 ip address 1.1.1.2 255.255.255.0

 tunnel source FastEthernet0/0

 tunnel destination 30.1.1.2

 

ip route 192.168.3.0 255.255.255.0 1.1.1.1

ip route 192.168.2.0 255.255.255.0 1.1.1.1

 

fenbu_2 路由器的配置:

interface Tunnel0

 ip address 2.1.1.2 255.255.255.0

 tunnel source FastEthernet0/0

 tunnel destination 30.1.1.2

ip route 192.168.3.0 255.255.255.0 2.1.1.1

ip route 192.168.1.0 255.255.255.0 2.1.1.1

 

查看路由表并测试:

zongbu#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 30.1.1.1 to network 0.0.0.0

 

     1.0.0.0/24 is subnetted, 1 subnets

C       1.1.1.0 is directly connected, Tunnel0

     2.0.0.0/24 is subnetted, 1 subnets

C       2.1.1.0 is directly connected, Tunnel1

     30.0.0.0/24 is subnetted, 1 subnets

C       30.1.1.0 is directly connected, FastEthernet0/0

S    192.168.1.0/24 [1/0] via 1.1.1.2

S    192.168.2.0/24 [1/0] via 2.1.1.2

C    192.168.3.0/24 is directly connected, FastEthernet0/1

S*   0.0.0.0/0 [1/0] via 30.1.1.1

 

fenbu_1#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 10.1.1.1 to network 0.0.0.0

 

     1.0.0.0/24 is subnetted, 1 subnets

C       1.1.1.0 is directly connected, Tunnel0

     10.0.0.0/24 is subnetted, 1 subnets

C       10.1.1.0 is directly connected, FastEthernet0/0

C    192.168.1.0/24 is directly connected, FastEthernet0/1

S    192.168.2.0/24 [1/0] via 1.1.1.1

S    192.168.3.0/24 [1/0] via 1.1.1.1

S*   0.0.0.0/0 [1/0] via 10.1.1.1

 

fenbu_2#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 20.1.1.1 to network 0.0.0.0

 

     2.0.0.0/24 is subnetted, 1 subnets

C       2.1.1.0 is directly connected, Tunnel0

     20.0.0.0/24 is subnetted, 1 subnets

C       20.1.1.0 is directly connected, FastEthernet0/0

S    192.168.1.0/24 [1/0] via 2.1.1.1

C    192.168.2.0/24 is directly connected, FastEthernet0/1

S    192.168.3.0/24 [1/0] via 2.1.1.1

S*   0.0.0.0/0 [1/0] via 20.1.1.1

 

测试方法:总部和各分部PC相互ping。

简要数据分析。根据路由表,以fenbu_1到总部为例。

Fenbu_1 到zongbu:

Fenbu_1 中的PC0(192.168.1.1/24)到zongbu的server(192.168.3.1/24),PC0的数据到达fenbu_1的路由器,查看路由表到达192.168.3.0/24的下一跳IP是1.1.1.1,路由器再次查找路由如何到1.1.1.1的,到达1.1.1.1是要从Tunnel0接口出去,此时路由器判断要对数据进行GRE封装处理,于是在原有的私有IP包报头前封装已经配置好的原公网IP(fa 0/0接口IP)和目标公网IP(即zongbu的fa 0/0接口IP),封装好后,路由器再次查找路由表发现到达zongbu的fa 0/0从缺省路由出去。就这样数据被送入Internet(公网),Internet(公网)的路由器直能查看公网IP报头,根据公网的目标IP转发数据。数据到达zongbu后,总部路由器首先看到路由器的目标IP是自己的,接受去除公网IP报头,发现是一个GRE数据,再根据私有IP报头中的私有目标IP再次查找数据,根据路由表将数据包从fa 0/1送至到server。Server接受数据,拆封数据查看内容,并产生回应IP包到fenbu_1的PC0。此后的过程跟从PC0到 server是一样的GRE操作。

未完待续。。。。。。

接下篇(http://9916376.blog.51cto.com/468239/269497)

(附件附有基本连通和完成配置)

转载于:https://blog.51cto.com/478239/268823