簡介
本檔案介紹當邊界閘道通訊協定(BGP)路由器沒有向對等點通告BGP路由時,如何進行疑難排解。
必要條件
需求
本文件沒有特定需求。
採用元件
本文件所述內容不限於特定軟體和硬體版本。但是,本文檔中顯示的輸出基於運行Cisco IOS®軟體版本12.2(24)a的Cisco 2500系列路由器。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
慣例
如需文件慣例的詳細資訊,請參閱思科技術提示慣例。
背景資訊
本文提供系統化方法,協助排除邊界閘道通訊協定(BGP)路由器沒有向對等點通告BGP路由的情況。
將字首新增到BGP表並向對等體通告的方式有多種:
-
在路由器BGP下發出basicnetworkcommand。此方法用於從自治系統(AS)發起BGP路由。如需更多資訊,請參閱BGP案例研究1的network命令一節。
-
Redistribute Interior Gateway Protocol(IGP)或靜態配置。
-
傳播從其他內部BGP(iBGP)或外部BGP(eBGP)對等點獲取的BGP路由。
注意:僅傳播從BGP對等點接收的最佳路徑。如需最佳路徑選取的詳細資訊,請參閱BGP最佳路徑選取演演算法。
-
發出aggregate-address命令。如需詳細資訊,請參閱瞭解BGP中的路由彙總。
使用基本Network語句通告的路由
當使用基本network語句通告路由時,etworkcommand的行為取決於是啟用還是禁用auto-summary。啟用自動摘要後,會將本地來源的BGP網路(networkx.x.x.x)總結到其有類邊界(BGP中預設啟用自動摘要)。如果路由表中存在子網並且滿足這三個條件,則本地路由表中該有類網路的任何子網(元件路由)都會提示BGP將有類網路安裝到BGP表中:
-
已啟用自動摘要
-
路由表中網路的有類network語句
-
該network語句上的有類掩碼
禁用自動總結時,本地引入到BGP表中的路由不會彙總到其有類邊界。
例如,如果符合以下條件,BGP會在BGP表中引入有類網路10.0.0.0掩碼255.0.0.0:
如果並非都符合這些條件,則BGP不會在BGP表中安裝條目,除非IP路由表中存在完全匹配的條目。
使用以下步驟進行疑難排解
在R101上啟用自動總結後,路由器無法向R102通告有類網路172.16.0.0/16。
路由器無法通告
-
檢查R101是否向R102宣佈172.16.0.0/16。顯示的輸出確認R101沒有向R102通告172.16.0.0/16。
R101#show ip bgp neighbors 10.10.10.2 advertised-routes
Total number of prefixes 0
R101#
-
檢查組態是否執行。所示示例說明了R101配置了有類network語句。用於此場景的Cisco IOS軟體版本預設啟用自動摘要。
R101#
show running-config | begin bgp
router bgp 1
network 172.16.0.0
neighbor 10.10.10.2 remote-as 2
[...]
-
檢查路由表中是否有network172.16.0.0/16的元件路由(有類路由或子網路由)。
R101#show ip route 172.16.0.0 255.255.0.0 longer-prefixes
Codes: L - local, 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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
R101#sh ip route 172.16.0.0 255.255.0.0 longer-prefixes
Codes: L - local, 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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
R101#
-
由於R101 IP路由表中沒有元件路由(無有類路由或子網路由),因此在BGP表中未安裝網路172.16.0.0。在etworkcommand(網路命令)下配置的字首安裝在BGP表中的最低要求是IP路由表中具有元件路由。因此,請確保R101具有網路172.16.0.0/16的元件路由。如果路由通過IGP或靜態配置獲知,則會完成此操作。在圖中所示的示例中,靜態路由配置為null 0。
R101(config)#ip route 172.16.10.0 255.255.255.0 null0 200
-
一旦IP路由表包含用於172.16.0.0/16的元件路由,BGP就會在BGP表中安裝有類網路。
R101#show ip route 172.16.0.0 255.255.0.0 longer-prefixes
Codes: L - local, 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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
S 172.16.10.0 is directly connected, Null0
若要使此更改在BGP中生效並開始向R102通告網路172.16.0.0/16,您必須清除BGP鄰居或執行對等體的軟重置。此範例顯示對等10.10.10.2的傳出軟重設以使變更生效。
R101#clear ip bgp 10.10.10.2 soft out
R101#
-
show ip bgp 命令確認有類網路172.16.0.0/16已引入到BGP中。
R101#show ip bgp | include 172.16.0.0
*> 172.16.0.0 0.0.0.0 0 32768 i
R101#
-
確認R101通告到R102的路由。
R101#show ip bgp neighbors 10.10.10.2 advertised-routes | include 172.16.0.0
*> 172.16.0.0 0.0.0.0 0 32768 i
注意:禁用auto-summary後,BGP會在路由表中與路由完全匹配時安裝網路172.16.0.0/16。如果有子網路由,但路由表中沒有與路由(172.16.0.0/16)完全匹配的路由,則BGP不會在BGP表中安裝網路172.16.0.0/16。
使用帶掩碼的Network語句通告的路由
位於主要網路邊界(255.0.0.0、255.255.0.0或255.255.255.0)上的網路不需要包含遮罩。例如,network 172.16.0.0命令足以將字首172.16.0.0/16傳送到BGP表中。但是,不位於主網邊界的網路需要具有帶掩碼的network語句,例如network 172.16.10.0 mask 255.255.255.0。
帶有掩碼的network語句需要路由表中的精確路由,才能將其安裝到BGP表中。
使用以下步驟進行疑難排解
R101無法向R102通告網路172.16.10.0/24。
無法向R102通告網路172.16.10.0/24
-
檢查R101是否向R102通告了172.16.10.0/24字首。
R101#show ip bgp neighbors 10.10.10.2 advertised-routes
R101#
或
此命令可用於檢查是否已通告路由:
R101#show ip bgp 172.16.10.0/24
R101# BGP routing table entry for 172.16.10.0/24, version 24480684
Bestpath Modifiers: deterministic-med
Paths: (4 available, best #3)
Not advertised to any peer
此輸出確認R101不會向R102通告192.168.32.0/22。
2.檢查配置是否運行。
R101#show run | begin bgp
router bgp 1
network 172.16.10.0
註:您需要發起網路172.16.10.0/24。此網路不屬於B類網路(255.255.0.0)的邊界。需要配置掩碼為255.255.255.0的network語句,以使其正常工作。
3.配置帶有掩碼的network語句後, show run命令會顯示類似以下的輸出:
R101#show run | begin bgp
router bgp 1
network 172.16.10.0 mask 255.255.255.0
-
檢查該路由是否在BGP路由表中。
R101#show ip bgp | include 172.16.10.0
R101#
BGP表中不存在網路172.16.10.0/24。
-
檢查IP路由表中是否有準確的路由。圖中所示的輸出確認路由表中沒有準確的路由。
R101#show ip route 172.16.10.0 255.255.255.0
% Network not in table
R101#
-
決定要發起哪些路由。然後修復IGP或配置靜態路由。
R101(config)#ip route 172.16.10.0 255.255.255.0 null0 200
-
檢查IP路由表。
R101#show ip route 172.16.10.0 255.255.255.0 longer-prefixes
[..]
172.16.0.0/24 is subnetted, 1 subnets
S 172.16.10.0 is directly connected, Null0
-
驗證路由是否在BGP表中。
R101#show ip bgp | include 172.16.10.0
*> 172.16.10.0/24 0.0.0.0 0 32768 i
-
若要使此更改在BGP中生效並開始向R102通告網路172.16.10.0/24,您必須清除BGP鄰居,或對對等體執行軟重置。此範例使用對等10.10.10.2的傳出軟重設。
R101#clear ip bgp 10.10.10.2 soft out
-
確認路由已通告給R102。
R101#show ip bgp neighbors 10.10.10.2 advertised-routes | include 172.16.10.0
*> 172.16.10.0/24 0.0.0.0 0 32768 i
使用aggregate-address命令通告的路由
BGP允許使用aggregate-address address address maskcommand將特定路由聚合到一條路由中。聚合適用於BGP路由表中存在的路由。這與etworkcommand(適用於IP路由表中存在的路由)相反。如果BGP路由表中至少存在聚合地址的一個或多個特定路由,則可以執行聚合。有關BGP聚合和相關屬性的詳細資訊,請參閱瞭解BGP中的路由聚合。
使用以下步驟解決此問題
使用aggregate-address命令通告的路由
在此網路圖中,R101無法向R102通告聚合地址192.168.32.0/22。網路192.168.32.0/22聚合了以下三個C類地址空間:
-
192.168.33.0/24
-
192.168.35.0/24
-
192.168.35.0/24
-
確認R101沒有向R102通告192.168.32.0/22。
R101#show ip bgp neighbors 10.10.10.2 advertised-routes | include 192.168.32.0
R101#
-
檢查組態是否執行。
router bgp 1
[..]
aggregate-address 192.168.32.0 255.255.252.0 summary-only
neighbor 10.10.10.2 remote-as 2
R101配置為僅向R102通告具有summary-only屬性的聚合地址。
3.檢查IP路由表。
R101#show ip route 192.168.32.0 255.255.252.0 longer-prefixes
[..]
S 192.168.33.0/24 is directly connected, Null0
IP路由表具有聚合192.168.32.0/22的元件路由;但是,要向對等體通告聚合地址,元件路由必須存在於BGP路由表中而不是IP路由表中。IP路由表具有聚合192.168.32.0/22的元件路由;但是,要向對等體通告聚合地址,元件路由必須存在於BGP路由表中而不是IP路由表中。
4.檢查BGP路由表中是否存在元件路由。
R101#show ip bgp 192.168.32.0 255.255.252.0 longer
R101#
輸出確認BGP表沒有元件路由,因此下一個邏輯步驟是確保BGP表中存在元件路由。
-
在本示例中,使用etworkcommand將元件路由192.168.33.0安裝到BGP表中。
R101(config)#router bgp 1
R101(config-router)# network 192.168.33.0
-
檢查BGP表中是否存在元件路由。
R101#show ip bgp 192.168.32.0 255.255.252.0 longer-prefixes
BGP table version is 8, local router ID is 10.10.20.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 192.168.32.0/22 0.0.0.0 32768 i
s> 192.168.33.0 0.0.0.0 0 32768 i
R101#
s表示由於僅摘要引數而禁止元件路由。
-
確認已向R102通告聚合。
R101#show ip bgp n 10.10.10.2 advertised-routes | include 192.168.32.0/22
*> 192.168.32.0/22 0.0.0.0
無法通告iBGP獲知的路由
如果啟用同步的BGP路由器無法驗證其IGP中的路由,則不會向其他eBGP對等體通告iBGP獲知的路由。IGP具有到iBGP獲知的路由的路由,路由器向eBGP對等體通告iBGP路由。否則,路由器將路由視為未與IGP同步,並且不會通告它。 要防止BGP從IGP中的iBGP路由驗證,請在路由器BGP下使用 no synchronization 命令禁用同步。有關詳細資訊,請參閱BGP案例研究的同步部分。
使用以下步驟進行疑難排解
在圖中,R101通過iBGP從R103獲取字首10.130.130.0/24,無法將其通告到eBGP對等體R102。
R101無法向eBGP對等體R102通告。
-
首先檢查R101。
R101#show ip bgp neighbors 10.10.20.2 advertised-routes | include 10.130.130.0
R101#
此輸出確認R101沒有向R102通告字首10.254.255.255/24。
檢視R101上的BGP表:
R101#show ip bgp 10.130.130.0 255.255.255.0 longer
BGP table version is 4, local router ID is 10.10.20.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i10.130.130.0/24 10.10.20.3 0 100 0 i
R101#
網路10.130.130.0/24存在於BGP表中。但是,網路10.130.130.0/24沒有最佳路由(>)的狀態代碼。這表示BGP最佳路徑選取演演算法未選擇此首碼作為最佳路徑。由於只向BGP對等點通告最佳路徑,因此不會向R102通告網路10.130.130.0/24。接下來,您需要排除BGP路徑選擇標準沒有選擇此網路作為最佳路由的原因。
-
檢查 show ip bgp prefix 命令的輸出,獲取更多有關為什麼未選擇字首作為最佳路由或安裝在IP路由表中的詳細資訊。
R101#show ip bgp 10.130.130.0
BGP routing table entry for 10.130.130.0/24, version 4
Paths: (1 available, no best path)
Not advertised to any peer
Local
10.10.20.3 from 10.10.20.3 (10.130.130.3)
Origin IGP, metric 0, localpref 100, valid, internal, not synchronized
輸出顯示字首10.130.130.0/24未同步。
註:在識別思科錯誤ID CSCdr90728(BGP路徑未標籤為未同步)之前,show ip bgp prefix 命令不會顯示標籤為未同步的路徑。Cisco IOS軟體版本12.1(4)和更新版本已更正此問題。
2.檢查BGP配置是否運行。
此輸出顯示BGP同步已啟用。Cisco IOS軟體預設啟用BGP同步。
R101#show ip protocols
Routing Protocol is "bgp 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
IGP synchronization is enabled
Automatic route summarization is disabled
Neighbor(s):
Address FiltIn FiltOut DistIn DistOut Weight RouteMap
10.10.10.2
10.10.20.3
Maximum path: 1
Routing for Networks:
Routing Information Sources:
Gateway Distance Last Update
10.10.20.3 200 01:48:24
Distance: external 20 internal 200 local 200
3.配置BGP以禁用同步。在路由器BGP下發出o命令。
R101(config)#router bgp 1
R101(config-router)# no synchronization
R101# show ip protocols
Routing Protocol is "bgp 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
IGP synchronization is disabled
Automatic route summarization is disabled
Neighbor(s):
Address FiltIn FiltOut DistIn DistOut Weight RouteMap
10.10.10.2
10.10.20.3
Maximum path: 1
Routing for Networks:
Routing Information Sources:
Gateway Distance Last Update
10.10.20.3 200 01:49:24
Distance: external 20 internal 200 local 200
BGP掃描程式每60秒掃描一次BGP表,並根據BGP路徑選擇標準做出決策。在下一次運行BGP掃描程式期間,將安裝網路10.130.130.0(因為同步已禁用)。這表示要安裝的路由的最長時間為60秒,但也可能更短,具體取決於何時配置 no synchronization 命令,以及何時發生下一個BGP掃描程式例項。因此,最好等待60秒再進行下一個驗證步驟。
-
驗證是否已安裝路由。
顯示的輸出確認字首10.130.130.0/24是最佳路由;因此,它被安裝到IP路由表中並傳播到對等10.10.10.2。
R101#show ip bgp 10.130.130.0
BGP routing table entry for 10.254.255.255/24, version 5
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Advertised to non peer-group peers:
10.10.10.2
Local
10.10.20.3 from 10.10.20.3 (10.130.130.3)
Origin IGP, metric 0, localpref 100, valid, internal, best
R101#show ip bgp neighbors 10.10.10.2 advertised-routes | include 10.130.130.0/24
*>i10.130.130.0/24 10.10.20.3 0 100 0 i
使用Redistribute靜態通告的路由
如果路由器連線到兩條鏈路,並且路由是通過BGP和浮動靜態路由獲知的,則浮動靜態路由將安裝在路由表中。如果在BGP路由失敗的情況下重新分配靜態路由,則會發生這種情況。如果BGP路由恢復聯機,則不會更改路由表中的浮動靜態路由來反映BGP路由。
如果您在BGP流程下移除 redistribute static命令以避免浮動靜態路由優先於BGP路由,就可以解決此問題。
相關資訊