幀中繼+重分發+管理距離(解決次優路由)

實驗列表:

1、實驗拓撲

2、查看配置完幀中繼及rip 、ospf後各路由器的路由表

3、重分發的影響

4、修改管理距離


1)實驗拓撲



2)各路由表

R2#sh ip rou
Codes: C - connected, S - static, 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
       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


     172.16.0.0/24 is subnetted, 2 subnets
C       172.16.1.0 is directly connected, Serial0/1
R       172.16.3.0 [120/1] via 172.16.1.1, 00:00:05, Serial0/1
     10.0.0.0/8 is variably subnetted, 7 subnets, 2 masks
O       10.10.10.10/32 [110/65] via 10.0.3.1, 00:15:10, Serial0/3
C       10.0.3.0/24 is directly connected, Serial0/3
O       10.0.0.0/24 [110/128] via 10.0.3.1, 00:15:10, Serial0/3
O       10.0.1.0/24 [110/192] via 10.0.3.1, 00:15:10, Serial0/3
O       10.100.100.100/32 [110/129] via 10.0.3.1, 00:15:11, Serial0/3
O       10.200.200.200/32 [110/193] via 10.0.3.1, 00:15:11, Serial0/3
C       10.222.222.222/32 is directly connected, Loopback1
R    192.168.1.0/24 [120/1] via 172.16.1.1, 00:00:06, Serial0/1


R3(config-router)#do sh ip rou
Gateway of last resort is not set


     172.16.0.0/24 is subnetted, 2 subnets
R       172.16.1.0 [120/1] via 172.16.3.1, 00:00:26, Serial0/2
C       172.16.3.0 is directly connected, Serial0/2
     10.0.0.0/8 is variably subnetted, 8 subnets, 2 masks
O       10.10.10.10/32 [110/129] via 10.0.1.1, 00:03:08, Serial0/0
O       10.0.3.0/24 [110/192] via 10.0.1.1, 00:03:08, Serial0/0
C       10.0.1.1/32 is directly connected, Serial0/0
O       10.0.0.0/24 [110/128] via 10.0.1.1, 00:03:08, Serial0/0
C       10.0.1.0/24 is directly connected, Serial0/0
O       10.100.100.100/32 [110/65] via 10.0.1.1, 00:03:10, Serial0/0
C       10.200.200.200/32 is directly connected, Loopback1
O       10.222.222.222/32 [110/193] via 10.0.1.1, 00:03:10, Serial0/0
R    192.168.1.0/24 [120/1] via 172.16.3.1, 00:00:01, Serial0/2


R7(config-router)#do sh ip rou
Gateway of last resort is not set


     172.16.0.0/24 is subnetted, 2 subnets
C       172.16.1.0 is directly connected, Serial0/0.1
C       172.16.3.0 is directly connected, Serial0/0.2
C    192.168.1.0/24 is directly connected, Ethernet1/0

5#sh ip rou
Gateway of last resort is not set


     10.0.0.0/8 is variably subnetted, 8 subnets, 2 masks
O       10.10.10.10/32 [110/65] via 10.0.0.1, 00:16:37, Serial0/1
O       10.0.3.0/24 [110/128] via 10.0.0.1, 00:16:37, Serial0/1
C       10.0.1.2/32 is directly connected, Serial0/0
C       10.0.0.0/24 is directly connected, Serial0/1
C       10.0.1.0/24 is directly connected, Serial0/0
C       10.100.100.100/32 is directly connected, Loopback1
O       10.200.200.200/32 [110/65] via 10.0.1.2, 00:16:37, Serial0/0
O       10.222.222.222/32 [110/129] via 10.0.0.1, 00:16:39, Serial0/1

3)在R2上將rip重分發到ospf中的結果(單點重分發)

R2#sh ip rou
Codes: C - connected, S - static, 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
       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


     172.16.0.0/24 is subnetted, 2 subnets
C       172.16.1.0 is directly connected, Serial0/1
R       172.16.3.0 [120/1] via 172.16.1.1, 00:00:23, Serial0/1
     10.0.0.0/8 is variably subnetted, 7 subnets, 2 masks
O       10.10.10.10/32 [110/65] via 10.0.3.1, 00:28:03, Serial0/3
C       10.0.3.0/24 is directly connected, Serial0/3
O       10.0.0.0/24 [110/128] via 10.0.3.1, 00:28:03, Serial0/3
O       10.0.1.0/24 [110/192] via 10.0.3.1, 00:28:03, Serial0/3
O       10.100.100.100/32 [110/129] via 10.0.3.1, 00:28:04, Serial0/3
O       10.200.200.200/32 [110/193] via 10.0.3.1, 00:28:04, Serial0/3
C       10.222.222.222/32 is directly connected, Loopback1
R    192.168.1.0/24 [120/1] via 172.16.1.1, 00:00:24, Serial0/1


R3(config-router)#do sh ip rou
Gateway of last resort is not set


     172.16.0.0/24 is subnetted, 2 subnets
O E2    172.16.1.0 [110/100] via 10.0.1.1, 00:29:04, Serial0/0
C       172.16.3.0 is directly connected, Serial0/2
     10.0.0.0/8 is variably subnetted, 8 subnets, 2 masks
O       10.10.10.10/32 [110/129] via 10.0.1.1, 00:29:04, Serial0/0
O       10.0.3.0/24 [110/192] via 10.0.1.1, 00:29:04, Serial0/0
C       10.0.1.1/32 is directly connected, Serial0/0
O       10.0.0.0/24 [110/128] via 10.0.1.1, 00:29:04, Serial0/0
C       10.0.1.0/24 is directly connected, Serial0/0
O       10.100.100.100/32 [110/65] via 10.0.1.1, 00:29:05, Serial0/0
C       10.200.200.200/32 is directly connected, Loopback1
O       10.222.222.222/32 [110/193] via 10.0.1.1, 00:29:05, Serial0/0
O E2 192.168.1.0/24 [110/100] via 10.0.1.1, 00:29:05, Serial0/0
R3(config-router)#

R5#sh ip rou
Gateway of last resort is not set


     172.16.0.0/24 is subnetted, 2 subnets
O E2    172.16.1.0 [110/100] via 10.0.0.1, 00:31:01, Serial0/1
O E2    172.16.3.0 [110/100] via 10.0.0.1, 00:31:01, Serial0/1
     10.0.0.0/8 is variably subnetted, 8 subnets, 2 masks
O       10.10.10.10/32 [110/65] via 10.0.0.1, 00:31:01, Serial0/1
O       10.0.3.0/24 [110/128] via 10.0.0.1, 00:31:01, Serial0/1
C       10.0.1.2/32 is directly connected, Serial0/0
C       10.0.0.0/24 is directly connected, Serial0/1
C       10.0.1.0/24 is directly connected, Serial0/0
C       10.100.100.100/32 is directly connected, Loopback1
O       10.200.200.200/32 [110/65] via 10.0.1.2, 00:31:02, Serial0/0
O       10.222.222.222/32 [110/129] via 10.0.0.1, 00:31:02, Serial0/1
O E2 192.168.1.0/24 [110/100] via 10.0.0.1, 00:31:02, Serial0/1


從R3路由表中的紅色文字可以知道,R3到達192.168.1.0網段沒有選擇最佳路由(R3-R7),而是選擇了次優路由(R3-R5-R4-R2-R7),即在R3上本地rip失效。爲什麼會出現這種情況呢?當外域路由重分發到ospf後,外域路由的管理距離變爲110,與此同時ospf更新lsa鏈路拓撲,這時對於R3而言出現了兩條運往192.168.1.0的路徑,根據路由器選擇最佳路由的原則,最終把ospf外域路由(ospf外域路由管理距離110<rip管理距離120)放入路由表中,這就是重分發後對邊界路由器(只有邊界路由纔出現這種情況)選擇最佳路由的影響。

4)修改管理距離

在有些情況下(比如重分發後路由),路由器相信的路由協議提供的路由更糟,但其管理距離更小,因此選擇次優路由。一種確保某種路由協議提供的路由被選中的方法是,給其他路由協議提供的路由協議指定較大的管理距離。本例中爲了解決路由重分發後不影響邊界路由器選擇最佳路由,可在出現選擇次優路由邊界路由器(不是作重分發的路由器)上修改外來路由的管理距離(注意修改管理距離只對本身路由器生效,不會傳到域內其他路由器,域內其他路由器對外來的路由管理距離依然不變(本例中爲110))

4.1、舉例:修改重分發路由器的外來路由管理距離不能影響域內其他路由器的外來路由管理距離但如果是在路由協議的redistribute命令中修改管理距離或打標籤之類(如將rip重分發到ospf中命令redistribute rip route-map xxx subnets,route-map中可以使用set修改管理距離與打標籤之類等 )就會全局ospf協議生效,在此章不做討論。

修改重分發路由器的域外路由管理距離R2(config-router)#distance ospf external 130  \\將域外路由管理值修改爲130

結果

R3#sh ip rou
Gateway of last resort is not set


     172.16.0.0/24 is subnetted, 2 subnets
O E2    172.16.1.0 [110/100] via 10.0.1.1, 01:20:38, Serial0/0
C       172.16.3.0 is directly connected, Serial0/2
     10.0.0.0/8 is variably subnetted, 8 subnets, 2 masks
O       10.10.10.10/32 [110/129] via 10.0.1.1, 01:20:38, Serial0/0
O       10.0.3.0/24 [110/192] via 10.0.1.1, 01:20:38, Serial0/0
C       10.0.1.1/32 is directly connected, Serial0/0
O       10.0.0.0/24 [110/128] via 10.0.1.1, 01:20:38, Serial0/0
C       10.0.1.0/24 is directly connected, Serial0/0
O       10.100.100.100/32 [110/65] via 10.0.1.1, 01:20:40, Serial0/0
C       10.200.200.200/32 is directly connected, Loopback1
O       10.222.222.222/32 [110/193] via 10.0.1.1, 01:20:40, Serial0/0
O E2 192.168.1.0/24 [110/100] via 10.0.1.1, 01:20:40, Serial0/0 \\邊界路由器R3還是選擇了次優路由(管理距離依然是110),表明修改重分發路由器管理距離不起作用。


修改管理R4域外管理距離

R4(config-router)#distance ospf ex 140

R4#sh ip rou
Gateway of last resort is not set


     172.16.0.0/24 is subnetted, 2 subnets
O E2    172.16.1.0 [140/100] via 10.0.3.2, 00:00:11, Serial0/3
O E2    172.16.3.0 [140/100] via 10.0.3.2, 00:00:11, Serial0/3
     10.0.0.0/8 is variably subnetted, 7 subnets, 2 masks
C       10.10.10.10/32 is directly connected, Loopback1
C       10.0.3.0/24 is directly connected, Serial0/3
C       10.0.0.0/24 is directly connected, Serial0/1
O       10.0.1.0/24 [110/128] via 10.0.0.2, 00:00:11, Serial0/1
O       10.100.100.100/32 [110/65] via 10.0.0.2, 00:00:13, Serial0/1
O       10.200.200.200/32 [110/129] via 10.0.0.2, 00:00:13, Serial0/1
O       10.222.222.222/32 [110/65] via 10.0.3.2, 00:00:13, Serial0/3
O E2 192.168.1.0/24 [140/100] via 10.0.3.2, 00:00:13, Serial0/3   \\說明本身域外路由管理距離值生效


而R5#sh ip rou
Gateway of last resort is not set


     172.16.0.0/24 is subnetted, 2 subnets
O E2    172.16.1.0 [110/100] via 10.0.0.1, 01:33:35, Serial0/1
O E2    172.16.3.0 [110/100] via 10.0.0.1, 01:33:35, Serial0/1
     10.0.0.0/8 is variably subnetted, 8 subnets, 2 masks
O       10.10.10.10/32 [110/65] via 10.0.0.1, 01:33:35, Serial0/1
O       10.0.3.0/24 [110/128] via 10.0.0.1, 01:33:35, Serial0/1
C       10.0.1.2/32 is directly connected, Serial0/0
C       10.0.0.0/24 is directly connected, Serial0/1
C       10.0.1.0/24 is directly connected, Serial0/0
C       10.100.100.100/32 is directly connected, Loopback1
O       10.200.200.200/32 [110/65] via 10.0.1.2, 01:33:36, Serial0/0
O       10.222.222.222/32 [110/129] via 10.0.0.1, 01:33:36, Serial0/1
O E2 192.168.1.0/24 [110/100] via 10.0.0.1, 01:33:36, Serial0/1  \\無論R2、R4域外管理距離怎麼變,都沒有影響到R5。


4.2、修改選擇次優路由的路由器R3。

方法1:R3(config-router)#distance ospf external 125 (也可以使用distance  125 10.0.0.0 0.255.255.255或者distance 125 0.0.0.0 255.255.255.255 access_list,而10.0.0.0或access_list裏邊的網段可以分開寫,但要包含域內所有路由器的網段

方法2:路由映射表

router ospf 1
 log-adjacency-changes
 network 10.0.1.0 0.0.0.255 area 0
 network 10.200.200.200 0.0.0.0 area 0
 distance 125 0.0.0.0 255.255.255.255 access_list

!
ip prefix-list net_10 seq 5 permit 10.0.0.0/8 le 32
!
route-map access_list permit 10
 match ip address net_10
!

其結果一樣

R3#sh ip rou

Gateway of last resort is not set


     172.16.0.0/24 is subnetted, 2 subnets
R       172.16.1.0 [120/1] via 172.16.3.1, 00:00:06, Serial0/2
C       172.16.3.0 is directly connected, Serial0/2
     10.0.0.0/8 is variably subnetted, 8 subnets, 2 masks
O       10.10.10.10/32 [110/129] via 10.0.1.1, 00:00:50, Serial0/0
O       10.0.3.0/24 [110/192] via 10.0.1.1, 00:00:50, Serial0/0
C       10.0.1.1/32 is directly connected, Serial0/0
O       10.0.0.0/24 [110/128] via 10.0.1.1, 00:00:50, Serial0/0
C       10.0.1.0/24 is directly connected, Serial0/0
O       10.100.100.100/32 [110/65] via 10.0.1.1, 00:00:52, Serial0/0
C       10.200.200.200/32 is directly connected, Loopback1
O       10.222.222.222/32 [110/193] via 10.0.1.1, 00:00:52, Serial0/0
R    192.168.1.0/24 [120/1] via 172.16.3.1, 00:00:07, Serial0/2    \\rip管理距離120<ospf域外管理距離125,終於選擇最優路由。



排查沒有選擇最優路由方法:命令traceroute和debug






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章