應用場景:
靜態路由的缺點是,必須手工配置,同時當網絡拓撲變化後需要手動更新;動態路由協議的缺點是,需要佔用網絡帶寬和路由器資源。在包含數百個分支的Hub-spoke網絡中,採用靜態路由的配置工作量非常大,而採用動態路由則將佔用大量的帶寬和資源。
在這種情況下,可以採用第三種方式,按需路由(ODR),ODR使用cisco發現協議(CDP)在分支和中央路由器之間傳輸網絡信息。
實驗拓撲:
路由器配置:
R1
conf t
int s0/2
ip add 12.1.1.1 255.255.255.252
no shut
int s0/3
ip add 13.1.1.1 255.255.255.252
no shut
exit
router odr
R2
conf t
int s0/0
ip add 12.1.1.2 255.255.255.252
no shut
int loop 1
ip add 2.2.2.2 255.255.255.0
R3
conf t
int s0/0
ip add 13.1.1.2 255.255.255.252
no shut
int loop 1
ip add 3.3.3.3 255.255.255.0
ODR配置非常簡單:
中央路由器上使用全局router odr配置ODR
末節點路由器無需任何配置
由於是基於CDP協議,CDP沒60s發送一次,可以使用全局命令cdp timer調整
在R1上查看路由表,
Gateway of last resort is not set
2.0.0.0/24 is subnetted, 1 subnets
o 2.2.2.0 [160/1] via 12.1.1.2, 00:00:27, Serial0/2
3.0.0.0/24 is subnetted, 1 subnets
o 3.3.3.0 [160/1] via 13.1.1.2, 00:00:02, Serial0/3
12.0.0.0/30 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial0/2
13.0.0.0/30 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, Serial0/3
可以看到2條o的路由(不要和OSPF的O混淆了)是R2和R3的LOOP網段
查看R2的路由表
Gateway of last resort is 12.1.1.1 to network 0.0.0.0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback1
12.0.0.0/30 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial0/0
o* 0.0.0.0/0 [160/1] via 12.1.1.1, 00:00:44, Serial0/0
有1條默認的指向R1的默認路由
總結:ODR雖然可以平衡一些靜態路由和動態路由的優缺,但是仍有一定的侷限:由於基於CDP協議,只適用cisco的設備,也只適用與中央-分支這類網絡拓撲。