9、發現隻要去traceroute 跟蹤一下通過10.1.255.5學到的位址,它就會變成走10.1.255.9,隻要路由表顯示通過10.1.255.9 的話。到目的網段就能通。但過一會就又會變成走10.1.255.5了。因為我們之前手動地指定了它的鄰居,是以當用路徑跟蹤這條路由後會發現自己的鄰居路由器的位址是10.1.255.9,進而把10.1.255.9當作最佳路徑來轉發了。
R4#traceroute 10.1.255.4
Type escape sequence to abort.
Tracing the route to 10.1.255.4
1 10.1.255.9 36 msec 56 msec 20 msec
2
R4#sh ip bgp
BGP table version is 245, local router ID is 10.1.255.13
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i10.1.255.0/30 10.1.255.5 0 100 0 i
* i10.1.255.4/30 10.1.255.5 0 100 0 i
*>i 10.1.255.9 0 100 0 i (成為最佳路徑了)
*> 10.1.255.8/30 0.0.0.0 0 32768 i
* i 10.1.255.9 0 100 0 i
*> 10.1.255.12/30 0.0.0.0 0 32768 i
* 10.1.255.14 0 0 64514 i
* i130.130.1.0/24 10.1.255.1 0 100 0 64512 i
*> 150.150.1.0/24 10.1.255.14 0 0 64514 i
R4#
R4#sh ip bgp 10.1.255.4
BGP routing table entry for 10.1.255.4/30, version 317
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x840
Advertised to update-groups:
2
Local
10.1.255.5 (inaccessible) from 10.1.255.5 (10.1.255.5) (發現選這條就是inaccessiable)
Origin IGP, metric 0, localpref 100, valid, internal
10.1.255.9 from 10.1.255.9 (10.1.255.9) (選這條就可以通了)
Origin IGP, metric 0, localpref 100, valid, internal, best
10、過一會之後,我們再看一下bgp表:
BGP table version is 219, local router ID is 10.1.255.13
*>i10.1.255.0/30 10.1.255.5 0 100 0 i
*>i10.1.255.4/30 10.1.255.5 0 100 0 i
* i 10.1.255.9 0 100 0 i(沒有成為最佳路徑了,這樣就不通)
*> 10.1.255.8/30 0.0.0.0 0 32768 i
*> 10.1.255.12/30 0.0.0.0 0 32768 i
*> 150.150.1.0/24 10.1.255.14 0 0 64514 i
11、再來看一下130.130.1.0/24在BGP表中的情況:
R4#sh ip bgp 130.130.1.0
BGP routing table entry for 130.130.1.0/24, version 0
Paths: (1 available, no best path)
Not advertised to any peer
64512
10.1.255.1 (inaccessible) from 10.1.255.5 (10.1.255.5)(隻有一條路徑,顯示下一跳不可達。)
Origin IGP, metric 0, localpref 100, valid, internal
12、再來看一下到10.1.255.0/30的bgp表:
R4#sh ip bgp 10.1.255.0
BGP routing table entry for 10.1.255.0/30, version 374
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
10.1.255.5 from 10.1.255.5 (10.1.255.5)
Origin IGP, metric 0, localpref 100, valid, internal, best(雖然是最佳的,但是下一跳是錯誤的)
R4#sh ip bgp 10.1.255.5
BGP routing table entry for 10.1.255.4/30, version 1053
10.1.255.5 (inaccessible) from 10.1.255.5 (10.1.255.5)(在這裡10.1.255.5并不可達。)
10.1.255.9 from 10.1.255.9 (10.1.255.9)
Origin IGP, metric 0, localpref 100, valid, internal, best
13、通過上圖分析,發現其實這些路由都存在于BGP表當中,能不能ping 通就看BGP有沒有把它當作最佳路徑和下一跳是否正确與可達。
三、造成以上的原因是:當兩條路由路徑成本(metric)都相等時,而且都來自于相同的自治系統的iBGP的鄰居,那麼會優先選擇router-id較小的iBGP鄰居的路由。從之前的圖中我們可以看到R4àR3與 R4àR2 (我們手動指定的鄰居産生的) metric都為0。
1、通過上述論述,我們需要在R2上指定一個較高的router-id,以讓R4放棄從R2而選擇R3這條路徑,那麼我們要把R2的router-id指定成比10.1.255.5 要高。
R2(config)#router bgp 64513
R2(config-router)#bgp router-id 172.1.255.5(指成172.1.255.5的話比10.1.255.9要高)
2、現在再來看一下R4上的路由表和BGP表,現在能全部學到了:
10.0.0.0/30 is subnetted, 4 subnets
B 10.1.255.4 [200/0] via 10.1.255.9, 00:03:21
B 10.1.255.0 [200/0] via 10.1.255.5, 00:02:28
C 10.1.255.12 is directly connected, Serial1/1
C 10.1.255.8 is directly connected, Serial1/0
130.130.0.0/24 is subnetted, 1 subnets
B 130.130.1.0 [200/0] via 10.1.255.1, 00:02:23
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 10.1.255.14, 03:23:35
BGP table version is 1083, local router ID is 10.1.255.13
*>i 10.1.255.9 0 100 0 i
*>i130.130.1.0/24 10.1.255.1 0 100 0 64512 i
3、從上面看出學到的10.1.255.4/30 是通過10.1.255.9/30 這個位址,這個位址是可達的。而10.1.255.0/30是通過10.1.255.5/30,之前是不可達。現在我們通過改router-id之後就變成可達的了:
BGP routing table entry for 10.1.255.0/30, version 1082
10.1.255.5 from 10.1.255.5 (192.16.255.5)
R4#ping 10.1.255.1
Sending 5, 100-byte ICMP Echos to 10.1.255.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/43/72 ms
四、總結:IBGP鄰居學來的資訊,不會傳遞給另外的IBGP鄰居,需要再手動去指定鄰居,BGP這條路徑能不能通,要看這條路徑否成為最佳路徑和下一跳是否正确與可達。當某個路由器到達一個網絡有兩條路徑,而且兩條路由路徑成本(metric)都相等時,并且都來自于相同的自治系統的iBGP的鄰居,那麼會優先選擇router-id較小的iBGP鄰居的路由。
本文轉自wxs-163 51CTO部落格,原文連結:http://blog.51cto.com/supercisco/268203