1. 程式人生 > >動態路由協議 雙點雙向重分佈 次優選路的解決辦法

動態路由協議 雙點雙向重分佈 次優選路的解決辦法

一.問題分析

對於動態路由協議(本實驗以rip和ospf為例),再進行雙點雙向重分佈時,可能存在問題:次優路徑

產生原因:把AD值高的路由協議(rip)重分佈到AD值低的路由協議(ospf)

實驗部署:R1、R2、R3執行rip協議,R2、R3、R4執行ospf協議,區域為area 0

然後在R2和R3分別將rip重分佈進ospf 1和ospf 1重分佈進rip

分析:R2可以通過兩種方式學習到R1的迴環介面1.1.1.1/32的路由,

第一種方式是R1通過rip將路由條目從s0/0發給R2的s0/0

第二種方式是R1通過rip將路由條目從s0/1發給R3,然後在R3將rip重分佈進ospf,再將ospf的路由資訊傳送給R4.最後R4轉發給R2的s0/1

比較這兩個路由資訊,R2從s0/0學習到的rip路由資訊AD為120,從s0/1學習到的ospf路由資訊AD為110,所以會優先選擇AD較小的路由條目即選擇第二條路由,然而這條路徑並不是最好的路徑。

檢視R2的路由表便可看到問題所在

R2#show ip route

     34.0.0.0/24 is subnetted, 1 subnets
O       34.1.1.0 [110/128] via 24.1.1.4, 00:05:13, Serial0/1
     1.0.0.0/32 is subnetted, 1 subnets
O E2    1.1.1.1 [110/20] via 24.1.1.4, 00:05:13, Serial0/1


     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/129] via 24.1.1.4, 00:05:13, Serial0/1
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 24.1.1.4, 00:05:13, Serial0/1
     24.0.0.0/24 is subnetted, 1 subnets
C       24.1.1.0 is directly connected, Serial0/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial0/0
     13.0.0.0/24 is subnetted, 1 subnets
O E2    13.1.1.0 [110/20] via 24.1.1.4, 00:05:16, Serial0/1

 


 

二.解決方法

 

方法一、修改重分發的路由(R2、R3)的管理距離 (此方法不太好)

R2(config)#router ospf 1                 //修改R2的管理距離

R2(config-router)#distance 121

R3(config)#router ospf 1                 //修改R3的管理距離

R3(config-router)#distance 121

將此協議的路由的AD改為121,對本協議所有路由都有效,改動範圍太大,通常不建議這樣做)

檢視R2(或R3)的路由表可見現在路徑是最優的,但是其他ospf路有條目的管理距離都被改為121,可見此方法不太好

R2#show ip route

     34.0.0.0/24 is subnetted, 1 subnets
O       34.1.1.0 [121/128] via 24.1.1.4, 00:00:03, Serial0/1
     1.0.0.0/32 is subnetted, 1 subnets
R       1.1.1.1 [120/1] via 12.1.1.1, 00:00:03, Serial0/0
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [121/129] via 24.1.1.4, 00:00:03, Serial0/1
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [121/65] via 24.1.1.4, 00:00:03, Serial0/1
     24.0.0.0/24 is subnetted, 1 subnets
C       24.1.1.0 is directly connected, Serial0/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial0/0
     13.0.0.0/24 is subnetted, 1 subnets
R       13.1.1.0 [120/1] via 12.1.1.1, 00:00:05, Serial0/0

 

方法二、只修改指定ADV router的路由的管理距離(必須路由的ADV router正確,通過show ip os da檢視)(此方法較好)

進入R2的ospf程序1,只將路由器3.3.3.3通告的OSPF路由AD改為121

R2(config)#router ospf 1               

R2(config-router)#distance 121 3.3.3.3 0.0.0.0  

進入R3的ospf程序1,只將路由器2.2.2.2通告的OSPF路由AD改為121

R3(config)#router ospf 1               

R3(config-router)#distance 121 2.2.2.2 0.0.0.0

註釋:0.0.0.0是反掩碼,用來對前面的2.2.2.2和3.3.3.3精確匹配

檢視R2的路由條目

R2#show ip route

     34.0.0.0/24 is subnetted, 1 subnets
O       34.1.1.0 [110/128] via 24.1.1.4, 00:04:03, Serial0/1
     1.0.0.0/32 is subnetted, 1 subnets
R       1.1.1.1 [120/1] via 12.1.1.1, 00:00:23, Serial0/0
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [121/129] via 24.1.1.4, 00:04:03, Serial0/1
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 24.1.1.4, 00:04:03, Serial0/1
     24.0.0.0/24 is subnetted, 1 subnets
C       24.1.1.0 is directly connected, Serial0/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial0/0
     13.0.0.0/24 is subnetted, 1 subnets
R       13.1.1.0 [120/1] via 12.1.1.1, 00:00:27, Serial0/0

說明:雖然路徑是最優的,不過 O       3.3.3.3 [121/129] via 24.1.1.4, 00:04:03, Serial0/1 這條路由條目的AD不需要修改才對,所以此方法不是最好的方法

 

方法三、精準抓取需要修改AD的路由條目對它進行修改(最好的方法)

R2(config)#access-list 1 permit 1.1.1.1 0.0.0.0
R2(config)#access-list 1 permit 13.1.1.0 0.0.0.255
R2(config)#router ospf 1
R2(config-router)#distance 121 3.3.3.3 0.0.0.0 1

(只針對3.3.3.3通告的1.1.1.0和13.1.1.0路由將AD改為121,對3.3.3.3通告的其它路由AD不變)

R3(config)#access-list 1 permit 1.1.1.1 0.0.0.0
R3(config)#access-list 1 permit 12.1.1.0 0.0.0.255
R3(config)#router ospf 1
R3(config-router)#distance 121 2.2.2.2 0.0.0.0 1

(只針對2.2.2.2通告的1.1.1.0和12.1.1.0路由將AD改為121,對2.2.2.2通告的其它路由AD不變)

檢視R2的路由條目可見其他ospf路由條目的AD並未改變,是最好的方法
R2#show ip route

     34.0.0.0/24 is subnetted, 1 subnets
O       34.1.1.0 [110/128] via 24.1.1.4, 00:03:21, Serial0/1
     1.0.0.0/32 is subnetted, 1 subnets
R       1.1.1.1 [120/1] via 12.1.1.1, 00:00:06, Serial0/0
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/129] via 24.1.1.4, 00:03:21, Serial0/1
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 24.1.1.4, 00:03:21, Serial0/1
     24.0.0.0/24 is subnetted, 1 subnets
C       24.1.1.0 is directly connected, Serial0/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial0/0
     13.0.0.0/24 is subnetted, 1 subnets
R       13.1.1.0 [120/1] via 12.1.1.1, 00:00:08, Serial0/0

 

方法四、還可以通過為OSPF設定外部路由的管理距離來解決,

只要將外部路由的管理距離增大到超過重分佈進來的協議的AD就可以了

R2(config)#router ospf 1

R2(config-router)#distance ospf external 121 inter-area 110 intra-area 110

R3(config)#router ospf 1

R3(config-router)#distance ospf external 121 inter-area 110 intra-area 110

此方法將rip重分發為ospf的路由(external )的管理距離修改為121,

域間路由(external )和域內路由(intra-area)管理距離仍為110