连接两个专用网络的简单GRE隧道

来源:百度文库 编辑:神马文学网 时间:2024/05/01 21:31:36
最基本的GRE实现是连接两个对等路由器GRE-1和GRE-2的GRE隧道。在本实例中,两个路由器通过串行链路连接,然后将GRE隧道创建在该链路之上。为了将通信嵌入到GRE隧道中,而不是让无封装的通信在普通串行链路上传输,两个路由器中都加入了一个静态的路由声明。这个静态路由基本规定了要到达另一个路由器后的专用网络,最佳路径就是通过隧道接口传输。在这些配置上还需要注意的是, 隧道接口的命名对于建立该隧道接口的路由器来说完全是局部的。连接到的另一个路由器则没有这个命名。另一个路由器关心隧道接口的配置而不是其命名。
tunnel source与tunnel destination命令基本确定了在GRE协议外部头里IP地址是多少。显然,如果你在Internet上发送GRE分组,则这些地址应当是全局可路由的。不过,封装在GRE分组中的分组不需要包含全局可路由的地址,因为GRE封装使这些地址对Internet隐藏。
从12.2版开始,Cisco IOS 软件就开始支持GRE keepalive。它允许GRE检查GRE隧道中源地址与目标地址间的路径是否已不再可用,在不可用时GRE隧道实际上转入了线协议。
在隧道接口中另一个选项也可启用。它们在本章前面RFC 1701的描述中已讨论过。
在这个实例研究中的场景是很典型的,即两个办公室使用GRE隧道相连接。这样的GRE隧道目的是使两个办公室的用户可以像访问同一网络一样访问对方的专用网络。尽管GRE允许两个网络连接到一起,但是GRE不提供安全性,例如它没有对通信加密。必须在应用层或是网络层中使用其他的方式提供这样的安全性。当使用带IPSec的GRE时,GRE keepalives将像其他通信一样被加密。同用户数据分组一样,如果IKE 和IPSec安全联盟在GRE隧道中并不是已经激活的,则第一个GRE keepalive分组将触发IKE/IPSec初始化。图11-5展示了本案例学习中讨论的GRE实现,同时例11-1展示了两个路由器的配置。
 
(点击查看大图)图11-5  本实例研究的GRE实现
例11-1  本实例研究中用到的两个路由器的配置
GRE-1#
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname GRE-1
!The tunnel interface is set up using the interface tunnel command. It is a
!logical interface.
 
interface Tunnel0
ip unnumbered Serial1
 
!The command below sets up the keepalive feature for GRE tunnels. Based on the
!parameters entered into this command, GRE keepalive packets are sent every 5
!seconds. 4 is the number of times this router continues sending keepalive
!packets without response before bringing the tunnel interface protocol down.
keepalive 5 4
!Tunnel source and destination specify the IP addresses that will be used as the
!source address and the destination address in the GRE header
(待续)
tunnel source Serial1
tunnel destination 50.1.1.2
!
interface Ethernet0
ip address 10.1.1.2 255.255.255.0
!
!
interface Serial1
ip address 50.1.1.1 255.255.255.0
encapsulation ppp
!
ip classless !The static route below is used to push traffic
destined for the network behind the
!other router, into the GRE tunnel
ip route 10.1.2.0 255.255.255.0 Tunnel0
! line con 0
line aux 0
line vty 0 4
login
!
end GRE-1# GRE-2#
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname GRE-2
ip subnet-zero
!The command below defines the tunnel interface
on this router. Please note that
!the numbering of the tunnels has only local significance. interface Tunnel0
ip unnumbered Serial0
keepalive 5 4
tunnel source Serial0
tunnel destination 50.1.1.1
!
interface Ethernet0
ip address 10.1.2.1 255.255.255.0
! !
interface Serial0
ip address 50.1.1.2 255.255.255.0
(待续)
encapsulation ppp
no fair-queue
clockrate 9600 !
ip classless
!The static route below is used to push traffic
destined for the network behind
!the other router, into the GRE tunnel
ip route 10.1.1.0 255.255.255.0 Tunnel0
no ip http server
!
!
line con 0
transport input none
line aux 0
line vty 0 4
!
end GRE-2#
这里的配置展示的是一个非常简单的使用静态路由的GRE实现。GRE也可以使用路由协议创建。在该例中GRE接口的功能同任何物理接口完全一样。