GRE ***是一种不加密的***,如果不用IPSec来保障安全性的话,他的所有信息都会暴露在互联网上,下面我们通过这个实验配置GRE *** 和 通过抓包来查看一下他的报文。


拓扑如下

cisco简单的GRE ***配置详解((不连续的ospf区域))

R1的配置

R1#conf t

R1(config)#int f0/1

R1(config-if)#ip add 12.1.1.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#int f0/0

R1(config-if)#ip add 13.1.1.1 255.255.255.0

R1(config-if)#no sh


R2的配置

R2#conf t

R2(config)#int f0/0

R2(config-if)#ip add 12.1.1.2 255.255.255.0

R2(config-if)#no sh

R2(config-if)#int lo 0

R2(config-if)#ip add 2.2.2.2 255.255.255.255

R2(config-if)#ip add 22.22.22.22 255.255.255.255 secondary     

R2(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.1     //配置默认路由,因为要先保证两个路由器需要做***的路由器在互联网上能互通

R2(config)#int tunnel 1   //进入tunnel接口

R2(config-if)#ip add 23.1.1.2 255.255.255.0    //配置一个虚拟的地址,两边的tunnel接口要在同一个网段才能实现通信

R2(config-if)#tunnel source f0/0             //指定源地址,可以是接口,也可以是12.1.1.2

R2(config-if)#tunnel destination 13.1.1.3    //指定目的地址,源目地址都是互联网上可以通信的地址

R2(config)#router ospf 1 //配置ospf

R2(config-router)#net 2.2.2.2 0.0.0.0 a 0

R2(config-router)#net 22.22.22.22 0.0.0.0 a 0

R2(config-router)#net 23.1.1.2 0.0.0.0 a 0 //把tunnel接口宣告进去,建立邻居


R3的配置

R3#conf t

R3(config)#int f0/0  

R3(config-if)#ip add 13.1.1.3 255.255.255.0

R3(config-if)#no sh

R3(config-if)#int lo 0

R3(config-if)#ip add 3.3.3.3 255.255.255.255

R3(config-if)#ip add 33.33.33.33 255.255.255.255 secondary 

R3(config-if)#ex

R3(config)#int tu 1

R3(config-if)#ip add 23.1.1.3 255.255.255.0

R3(config-if)#tu so f0/0

R3(config-if)#tu de 13.1.1.3   

R3(config)#ip route 0.0.0.0 0.0.0.0 13.1.1.1

R3(config)#router os 1

R3(config-router)#net 23.1.1.3 0.0.0.0 a 0

R3(config-router)#net 3.3.3.3 0.0.0.0 a 0

R3(config-router)#net 33.33.33.33 0.0.0.0 a 0


查看路由表

R2

R2#show ip rou os

     33.0.0.0/32 is subnetted, 1 subnets

O       33.33.33.33 [110/11112] via 23.1.1.3, 00:00:06, Tunnel1

     3.0.0.0/32 is subnetted, 1 subnets

O       3.3.3.3 [110/11112] via 23.1.1.3, 00:00:16, Tunnel1


R3

R3#show ip route ospf

     2.0.0.0/32 is subnetted, 1 subnets

O       2.2.2.2 [110/11112] via 23.1.1.2, 00:21:36, Tunnel1

     22.0.0.0/32 is subnetted, 1 subnets

O       22.22.22.22 [110/11112] via 23.1.1.2, 00:21:36, Tunnel1


R2#show ip ospf int brief 

Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C

Tu1          1     0               23.1.1.2/24        11111 P2P   1/1

Lo0          1     0               2.2.2.2/32         1     LOOP  0/0


可以看出,在ospf中,tunnel的默认cost是11111 网络类型为P2P


下面我们在R1-R3的线路抓包


在R2上用2.2.2.2去ping R3的 3.3.3.3


cisco简单的GRE ***配置详解((不连续的ospf区域))


在这个机制下,通过抓包我们可以看到,内网是完全暴露在互联网中的。


cisco简单的GRE ***配置详解((不连续的ospf区域))


cisco简单的GRE ***配置详解((不连续的ospf区域))


可以看到,tunnel源目IP地址十分明了,实际上这个是极为不安全的,但是我们可以使用GRE+IPSec来保证它的安全性