7、為什麼學不到不是直連的EBGP路由?分析其原因是由IBGP鄰居學來的資訊産生如下結果:
A:如果在R2àR4上同步關閉,則會将IBGP資訊傳遞給EBGP鄰居 (12.3以上IOS版本的路由器預設為同步關閉狀态)
B:如果在R2àR4上同步開啟,則不會将IBGP資訊傳遞給EBGP鄰居。原因為:BGP要求,從IBGP鄰居學來的路由資訊理應不傳遞給EBGP鄰居,因為直接從IBGP鄰居學來的路由資訊并不一定是可達的路由。那麼我們看一下R2的BGP表,看有沒有這條路由存在:
R2#sh ip bgp
BGP table version is 10, local router ID is 192.16.255.5
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
* 10.1.255.0/30 10.1.255.1 0 0 64512 i
*> 0.0.0.0 0 32768 i
*> 10.1.255.4/30 0.0.0.0 0 32768 i
* i 10.1.255.6 0 100 0 i
r i10.1.255.8/30 10.1.255.10 0 100 0 i
r>i 10.1.255.6 0 100 0 i
r>i10.1.255.12/30 10.1.255.10 0 100 0 i
*> 130.130.1.0/24 10.1.255.1 0 0 64512 i
* i150.150.1.0/24 10.1.255.14 0 100 0 64514 i(發現BGP中存在這條路由,
但沒有被選為選中最佳)
8、再看一下150.150.1.0/24
R2#sh ip bgp 150.150.1.0
BGP routing table entry for 150.150.1.0/24, version 0
Paths: (1 available, no best path)
Not advertised to any peer
64514
10.1.255.14 (metric 192) from 10.1.255.10 (10.1.255.13)
Origin IGP, metric 0, localpref 100, valid, internal, not synchronized (沒同步起來)
三、用上述指令一步一步排錯是最好不過了。根據BGP同步規則,開啟同步的話,邊緣路由器不使用或不通告給任何EBGP鄰居從IBGP鄰居學習到的路由,在運作了其它系統,并且同步是開啟狀态。通過重分發讓IGP中也學習到EGP的路由,圖中可以是在R2和R4當中使用重分發bgp的路由到ospf 當中,讓R2和R4學到EBGP的路由,EBGP也能學到IBGP的路由:
R2(config)#router ospf 1
R2(config-router)#redistribute bgp 64513 metric 200 subnets
R4(config)#router ospf 1
R4(config-router)#redistribute bgp 64513 metric 200 subnets
2、現在再看一下R1和R4:
R1#sh ip route
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
10.0.0.0/30 is subnetted, 4 subnets
B 10.1.255.4 [20/0] via 10.1.255.2, 00:10:16
C 10.1.255.0 is directly connected, Serial1/1
B 10.1.255.12 [20/0] via 10.1.255.2, 00:10:47
B 10.1.255.8 [20/0] via 10.1.255.2, 00:10:47
130.130.0.0/24 is subnetted, 1 subnets
C 130.130.1.0 is directly connected, Loopback0
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 10.1.255.2, 00:01:07
R4#sh ip route
O 10.1.255.4 [110/128] via 10.1.255.9, 00:01:21, Serial1/0
O 10.1.255.0 [110/192] via 10.1.255.9, 00:01:21, Serial1/0
C 10.1.255.12 is directly connected, Serial1/1
C 10.1.255.8 is directly connected, Serial1/0
O E2 130.130.1.0 [110/200] via 10.1.255.9, 00:01:21, Serial1/0 (會以2類的OE 來顯示了)
B 150.150.1.0 [20/0] via 10.1.255.14, 00:12:37
3、現在能學到了,我們再來到R2上看一下和150.150.1.0/30的同步關系:
BGP routing table entry for 150.150.1.0/24, version 16
Paths: (1 available, best #1, table Default-IP-Routing-Table, RIB-failure(17))
Advertised to update-groups:
1
Origin IGP, metric 0, localpref 100, valid, internal, synchronized, best (現在同步了)
4、由于在上圖顯示R4學到130.130.1.0/24以 0E2來顯示,是以說會造成R5學不到130.130.1.0這條路由。因為在R4上就不存在這條路由。補充一下重要的事情:請把R2當時設定的BGP router-id no 掉。讓R4學到130.130.1.0/24并以bgp最佳形式存在,因為根據BGP同步規則:需要IBGP也學習到相同路由,不然不通告給任何EBGP鄰居從IBGP鄰居學習到路由:
R2(config)#router bgp 64513
R2(config-router)#no router-id 172.16.255.5 (no 掉之前在R2上指高的router-id)
5、保證在R4上存在最佳路徑的BGP。如以這樣顯示:(r>i)
<a></a>
R4#sh ip bgp
…………
r>i10.1.255.0/30 10.1.255.5 0 100 0 i
r>i10.1.255.4/30 10.1.255.9 0 100 0 i
r i 10.1.255.5 0 100 0 i
* i10.1.255.8/30 10.1.255.9 0 100 0 i
* 10.1.255.12/30 10.1.255.14 0 0 64514 i
r>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
6、現在R5上也正常了:
R5#sh ip route
………………
B 10.1.255.4 [20/0] via 10.1.255.13, 00:07:17
B 10.1.255.0 [20/0] via 10.1.255.13, 00:07:17
C 10.1.255.12 is directly connected, Serial1/0
B 10.1.255.8 [20/0] via 10.1.255.13, 00:07:17
B 130.130.1.0 [20/0] via 10.1.255.13, 00:07:47
C 150.150.1.0 is directly connected, Loopback0
四、總結:在BGP當中,IBGP的路由器關閉同步則會将IBGP資訊傳遞給EBGP鄰居,如果開啟同步,則不會将IBGP資訊傳遞給EBGP鄰居。原因是BGP要求,從IBGP鄰居學來的路由資訊理應不傳遞給EBGP鄰居,因為直接從IBGP鄰居學來的路由資訊并不一定是可達的路由。如果開啟同步并運作了不同系統。可以在邊緣路由器上用重分發把EGP釋出到IGP當中,直到IGP中也學習到EGP路由。這樣所有的BGP路由都能學到。
本文轉自wxs-163 51CTO部落格,原文連結:http://blog.51cto.com/supercisco/268998