按需路由选择原理
 
       静态路由的缺点是,必须手工配置,同时在网络拓扑变化后需要手工更新;动态路由选择协议的缺点是,它们需要占用网络带宽和路由器资源。在包含数百个分支点的中央-分支网络中,采用静态路由时配置工作量将非常大;而采用动态路由选择协议时将占用大量的资源。
 
       在这种情况下,可采用第三种方式:按需路由选择(ODR)。ODR使用Cisco发现协议(CDP)来在分支(末节)路由器和中央路由器之间传输网络信息。与动态路由选择协议相比,ODR提供IP路由选择信息的开销非常小;而与静态路由相比,ODR的手工配置量更少。
 
       ODR只适合用于中央-分支拓扑。在这种拓扑中,每台分支路由器只与中央路由器相邻。分支路由器也被称为末节路由器。末节路由器可能连接了几个LAN,但通常只有一条到中央路由器的WAN连接。中央路由器需要获悉每台分支路由器连接的网络,而分支路由器只需要一条指向中央路由器的默认路由。
 
       配置ODR后,末节路由器使用CDP将IP前缀信息发送给中央路由器。末节路由器发送其所有直连网络的前缀信息。ODR报告子网掩码,因此支持变长子网掩码(VLSM)。
 
       ODR依赖于CDP在中央路由器和分支路由器之间传输信息,因此在中央路由器和分支路由器之间的所有链路上都必须启用CDP。默认情况下,Cisco路由器全局地启用CDP,并在各个接口上启用CDP。然而,在有些WAN链路(如ATM)上,必须显式地启用CDP。
 
       中央路由器将一条指向自己的默认路由发送给分支路由器,并将ODR报告的末节网络加入到路由选择表中,可对中央路由器进行配置,使之将这些网络重分发给动态路由选择协议。中央路由器将ODR报告分支路由器的IP地址用作下一跳地址。
 
       ODR并非一种路由选择协议,因为它交换的信息仅限于IP前缀和默认路由。ODR不报告度量值,对于ODR报告的所有路由,中央路由器都将其度量值设置为1跳。然而,使用ODR,可以动态地获悉有关末节网络的路由选择信息,而不存在动态路由选择协议所需的开销;同时,无需手工配置,就能够给末节路由器提供一条默认路由。
ODR简介:
  ODR技术(IOS 12.0.5T)能够使hub and spoke网络结构中的hub路由器自动地向spoke路由器(又称为stub站点)提供缺省路由,stub站点路由器不需要运行动态路由协议,也不需要配置任何的静态路由,几乎没有系统资源的占用,就能够实现本地所有的直连子网向hub路由器的自动通告.
3.ODR需求:
  ODR使用Cisco Discovery Protocol (CDP)在hub路由器和spoke路由器之间传递路由信息,因此需要在hub和spoke路由之间的每条链路上启用cdp协议,cdp是一个data-link层协议,可以运行在Lan/serial/frame-relay/atm等传输介质上.
4.(.NET文件的)拓扑图如下:
autostart = False
[localhost]
`3640`
p_w_picpath = C:\Program Files\Dynamips\p_w_picpaths\C3640-JS.BIN
ram = 128
idlepc = 0xffffffff80425144
confreg = 0x2142
`ROUTER Router1`
model = 3640
console = 2001
slot0 = NM-1E
slot1 = NM-4T
E0/0 = Router2 E0/0
S1/0 = Router3 S1/0
S1/1 = Router4 S1/1
`ROUTER Router2`
model = 3640
console = 2002
slot0 = NM-1E
slot1 = NM-4T
`ROUTER Router3`
model = 3640
console = 2003
slot0 = NM-1E
slot1 = NM-4T
`ROUTER Router4`
model = 3640
console = 2004
slot0 = NM-1E
slot1 = NM-4T
5.配置如下:
RouterA:
en
config t
host RouterA
inter e0/0
ip add 192.168.1.1 255.255.255.0
no shut
inter s1/0
ip add 192.168.2.1 255.255.255.0
no shut
inter s1/1
ip add 192.168.3.1 255.255.255.0
exit
router odr
RouterB:
en
config t
host RouterB
inter e0/0
ip add 192.168.1.2 255.255.255.0
no shut
inter loopback 0
ip add 166.1.1.1 255.255.255.0
exit
RouterC:
en
config t
host RouterC
inter s1/0
ip add 192.168.2.2 255.255.255.0
no shut
inter loopback 0
ip add 177.2.2.2 255.255.255.0
exit
RouterD:
en
config t
host RouterD
inter s1/1
ip add 192.168.3.2 255.255.255.0
no shut
inter loopback 0
ip add 188.3.3.3 255.255.255.0
exit
6:验证结果
RouterA:
RouterA#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, su - IS-IS summary, 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 not set
     188.3.0.0/24 is subnetted, 1 subnets
o       188.3.3.0 [160/1] via 192.168.3.2, 00:00:49, Serial1/1
     177.2.0.0/24 is subnetted, 1 subnets
o       177.2.2.0 [160/1] via 192.168.2.2, 00:00:13, Serial1/0
     166.1.0.0/24 is subnetted, 1 subnets
o       166.1.1.0 [160/1] via 192.168.1.2, 00:00:01, Ethernet0/0
C    192.168.1.0/24 is directly connected, Ethernet0/0
C    192.168.2.0/24 is directly connected, Serial1/0
C    192.168.3.0/24 is directly connected, Serial1/1
RouterA#
RouterB:
RouterB#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, su - IS-IS summary, 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 192.168.1.1 to network 0.0.0.0
     166.1.0.0/24 is subnetted, 1 subnets
C       166.1.1.0 is directly connected, Loopback0
C    192.168.1.0/24 is directly connected, Ethernet0/0
o*   0.0.0.0/0 [160/1] via 192.168.1.1, 00:00:17, Ethernet0/0
RouterB#
RouterC:
RouterC#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, su - IS-IS summary, 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 192.168.2.1 to network 0.0.0.0
     177.2.0.0/24 is subnetted, 1 subnets
C       177.2.2.0 is directly connected, Loopback0
C    192.168.2.0/24 is directly connected, Serial1/0
o*   0.0.0.0/0 [160/1] via 192.168.2.1, 00:00:22, Serial1/0
RouterC#
RouterD:
RouterD#
RouterD#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, su - IS-IS summary, 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 192.168.3.1 to network 0.0.0.0
     188.3.0.0/24 is subnetted, 1 subnets
C       188.3.3.0 is directly connected, Loopback0
C    192.168.3.0/24 is directly connected, Serial1/1
o*   0.0.0.0/0 [160/1] via 192.168.3.1, 00:00:26, Serial1/1
RouterD#
OVER!