本文說明如何使用可選引數配置BGP路由聚合。
思科建議您瞭解下列主題:
本檔案中的資訊是根據Cisco IOS XE軟體版本17.x。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
BGP路由聚合允許將多個特定路由合併到單個總結路由(聚合路由)中,以減少路由表大小和通告開銷。
可選關鍵字包括:
預設情況下,aggregate-address命令僅在至少存在一條更具體的路由時才會生成摘要地址,而不會繼承AS路徑。

這是rtr3初始配置。
rtr3#show running-config | sec router bgp
router bgp 65333
bgp log-neighbor-changes
neighbor 10.13.13.1 remote-as 65111
neighbor 10.23.23.2 remote-as 65222
neighbor 10.34.34.4 remote-as 65444
這是rtr3上的BGP表。
rtr3#show ip bgp
BGP table version is 9, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/32 10.13.13.1 0 0 65111 i
*> 10.1.1.1/32 10.13.13.1 0 0 65111 i
*> 10.1.1.2/32 10.13.13.1 0 0 65111 i
*> 10.1.1.3/32 10.13.13.1 0 0 65111 i
*> 10.2.2.0/32 10.23.23.2 0 0 65222 i
*> 10.2.2.1/32 10.23.23.2 0 0 65222 i
*> 10.2.2.2/32 10.23.23.2 0 0 65222 i
*> 10.2.2.3/32 10.23.23.2 0 0 65222 i
請注意rtr3具有來自rtr1(AS 65111)和rtr2(AS 65222)的所有特定字首。rtr3將這些字首通告給rtr4,並將AS 65333新增到AS PATH屬性。
rtr4收到的資訊如下:
rtr4#show ip bgp
BGP table version is 9, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/32 10.34.34.3 0 65333 65111 i
*> 10.1.1.1/32 10.34.34.3 0 65333 65111 i
*> 10.1.1.2/32 10.34.34.3 0 65333 65111 i
*> 10.1.1.3/32 10.34.34.3 0 65333 65111 i
*> 10.2.2.0/32 10.34.34.3 0 65333 65222 i
*> 10.2.2.1/32 10.34.34.3 0 65333 65222 i
*> 10.2.2.2/32 10.34.34.3 0 65333 65222 i
*> 10.2.2.3/32 10.34.34.3 0 65333 65222 i
配置BGP以僅通告聚合地址。
在第一個實際示例中,您希望rtr4隻接收字首10.0.0.0/8。
rtr3(config)#router bgp 65333
rtr3(config-router)#aggregate-address 10.0.0.0 255.0.0.0 summary-only
rtr3(config-router)#exit
rtr3(config)#
建立聚合後rtr4上的BGP表:
rtr4#show ip bgp
BGP table version is 18, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.0.0.0 10.34.34.3 0 0 65333 i
注意AS路徑是如何運65333的(發起總結的路由器)。
在第二個實際示例中,您將看到如何跟蹤原始AS-PATH。
這是rtr3配置。
rtr3#configure terminal
rtr3(config)#router bgp 65333
rtr3(config-router)#aggregate-address 10.0.0.0 255.0.0.0 as-set summary-only
rtr3(config-router)#exit
這是rtr4上的BGP表。
rtr4#show ip bgp
BGP table version is 36, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.0.0.0 10.34.34.3 0 0 65333 {65111,65222} i
請注意,您有rtr3聚合的所有AS路徑。
使用路由對映取消BGP字首。
在第三個實際示例中,您將配置一個路由對映以過濾來自rtr1的字首。
rtr3(config)#ip prefix-list suppress_rtr1 permit 10.1.1.0/24 le 32
rtr3(config)#route-map SUPPRESS-RTR1 permit 10
rtr3(config-route-map)#match ip address prefix-list suppress_rtr1
rtr3(config)#
rtr3(config)#router bgp 65333
rtr3(config-router)#aggregate-address 10.0.0.0 255.0.0.0 suppress-map SUPPRESS-RTR1
rtr3(config-router)#end
rtr3#
這是rtr3上的BGP表。
rtr3#show ip bgp
BGP table version is 114, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.0.0.0 0.0.0.0 32768 i
s> 10.1.1.0/32 10.13.13.1 0 0 65111 i
s> 10.1.1.1/32 10.13.13.1 0 0 65111 i
s> 10.1.1.2/32 10.13.13.1 0 0 65111 i
s> 10.1.1.3/32 10.13.13.1 0 0 65111 i
*> 10.2.2.0/32 10.23.23.2 0 0 65222 i
*> 10.2.2.1/32 10.23.23.2 0 0 65222 i
*> 10.2.2.2/32 10.23.23.2 0 0 65222 i
*> 10.2.2.3/32 10.23.23.2 0 0 65222 i
請注意僅隱藏來自rtr1的字首。
這是rtr4上的BGP表。
rtr4#show ip bgp
BGP table version is 114, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.0.0.0 10.34.34.3 0 0 65333 i
*> 10.2.2.0/32 10.34.34.3 0 65333 65222 i
*> 10.2.2.1/32 10.34.34.3 0 65333 65222 i
*> 10.2.2.2/32 10.34.34.3 0 65333 65222 i
*> 10.2.2.3/32 10.34.34.3 0 65333 65222 i
rtr4#
僅當BGP表中存在範圍內的字首時通告彙總路由。
在第四個示例中,您將使用先前配置的相同路由對映,該路由對映禁止所有來自rtr1的字首。
rtr3(config)#router bgp 65333
rtr3(config-router)#aggregate-address 10.0.0.0 255.0.0.0 advertise-map SUPPRESS-RTR1 summary-only
advertise-map設定一個條件,只有在BGP表中存在10.1.1.0/24範圍內的任何字首時,才會生成僅摘要聚合。
這是rtr3上的BGP表。
rtr3#show ip bgp
BGP table version is 148, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.0.0.0 0.0.0.0 32768 i
s> 10.1.1.0/32 10.13.13.1 0 0 65111 i
s> 10.1.1.1/32 10.13.13.1 0 0 65111 i
s> 10.1.1.2/32 10.13.13.1 0 0 65111 i
s> 10.1.1.3/32 10.13.13.1 0 0 65111 i
s> 10.2.2.0/32 10.23.23.2 0 0 65222 i
s> 10.2.2.1/32 10.23.23.2 0 0 65222 i
s> 10.2.2.2/32 10.23.23.2 0 0 65222 i
s> 10.2.2.3/32 10.23.23.2 0 0 65222 i
以下是沒有與路由對映匹配的字首時的輸出:
rtr3#show run | section router bgp
router bgp 65333
aggregate-address 10.0.0.0 255.0.0.0 summary-only advertise-map SUPPRESS-RTR1
neighbor 10.13.13.1 remote-as 65111
neighbor 10.23.23.2 remote-as 65222
neighbor 10.34.34.4 remote-as 65444
!
rtr3#show ip bgp
BGP table version is 31, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.2.2.0/32 10.23.23.2 0 0 65222 i
*> 10.2.2.1/32 10.23.23.2 0 0 65222 i
*> 10.2.2.2/32 10.23.23.2 0 0 65222 i
*> 10.2.2.3/32 10.23.23.2 0 0 65222 i
請注意,來自rtr2的字首不會被抑制,也不會生成aggregate-route。
使用路由對映配置BGP屬性。
rtr3(config)#route-map BGP-ATTR permit 10
rtr3(config-route-map)#set community no-export
rtr3(config-route-map)#exit
rtr3(config)#router bgp 65333
rtr3(config-router)#aggregate-address 10.0.0.0 255.0.0.0 attribute-map BGP-ATTR summary-only
如果檢查以檢視生成的聚合地址,您會發現它表明沒有通告給任何對等體。這種情況是預期發生,因為所有鄰居都是外部(eBGP),並且您正在設定非匯出已知社群。由於使用了僅摘要引數,rtr4未收到任何路由。
這是rtr3上的BGP表
rtr3#show ip bgp 10.0.0.0
BGP routing table entry for 10.0.0.0/8, version 20
Paths: (1 available, best #1, table default, not advertised to EBGP peer)
Not advertised to any peer
Refresh Epoch 1
Local, (aggregated by 65333 10.34.34.3)
0.0.0.0 from 0.0.0.0 (10.34.34.3)
Origin IGP, localpref 100, weight 32768, valid, aggregated, local, atomic-aggregate, best
Community: no-export
rx pathid: 0, tx pathid: 0x0
Updated on Jun 12 2026 23:14:53 UTC
若要確認BGP路由聚合是否正常工作,如果您僅接收我們希望看到的內容,可以檢查接收路由器(本例中為rtr4)上的可見內容。例如,只有summary、summary以及所有特定字首、summary和僅一些特定字首等。您可以主要使用以下命令:
如需進一步的詳細資訊,請參閱疑難排解案例。
未收到總結路由,仍然看到特定字首。
rtr4#show ip bgp
BGP table version is 9, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/32 10.34.34.3 0 65333 65111 i
*> 10.1.1.1/32 10.34.34.3 0 65333 65111 i
*> 10.1.1.2/32 10.34.34.3 0 65333 65111 i
*> 10.1.1.3/32 10.34.34.3 0 65333 65111 i
*> 10.2.2.0/32 10.34.34.3 0 65333 65222 i
*> 10.2.2.1/32 10.34.34.3 0 65333 65222 i
*> 10.2.2.2/32 10.34.34.3 0 65333 65222 i
*> 10.2.2.3/32 10.34.34.3 0 65333 65222 i
驗證是否將summary-only配置為aggregate-address的引數,以及子網掩碼是否正確。
這是rtr3配置。
rtr3(config)#router bgp 65333
rtr3(config-router)#aggregate-address 10.0.0.0 255.255.255.0 summary-only
rtr3(config-router)#exit
rtr3(config)#
在本例中,配置了summary-address ,但子網掩碼不正確。只有10.0.0.0/24網路中的字首屬於聚合,這會破壞BGP路由聚合規則。所有來自rtr1和rtr2的字首都位於摘要範圍之外,如果您檢查rtr3上的BGP表,則不會發生抑制。
rtr3 — 已更正的配置。
rtr3(config)#router bgp 65333
rtr3(config-router)#aggregate-address 10.0.0.0 255.0.0.0 summary-only
rtr3(config-router)#exit
rtr3(config)#
現在將特定字首標籤為隱藏。
rtr3#show ip bgp
BGP table version is 18, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.0.0.0 0.0.0.0 32768 i
s> 10.1.1.0/32 10.13.13.1 0 0 65111 i
s> 10.1.1.1/32 10.13.13.1 0 0 65111 i
s> 10.1.1.2/32 10.13.13.1 0 0 65111 i
s> 10.1.1.3/32 10.13.13.1 0 0 65111 i
s> 10.2.2.0/32 10.23.23.2 0 0 65222 i
s> 10.2.2.1/32 10.23.23.2 0 0 65222 i
s> 10.2.2.2/32 10.23.23.2 0 0 65222 i
s> 10.2.2.3/32 10.23.23.2 0 0 65222 i
隱藏對映配置為隱藏範圍,但沒有隱藏任何內容。
請考慮使用rtr3上的BGP表。您想要取消所有10.2.2.0/24字首,但在應用配置後,它不工作。
rtr3#show ip bgp
BGP table version is 37, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/32 10.13.13.1 0 0 65111 i
*> 10.1.1.1/32 10.13.13.1 0 0 65111 i
*> 10.1.1.2/32 10.13.13.1 0 0 65111 i
*> 10.1.1.3/32 10.13.13.1 0 0 65111 i
*> 10.2.2.0/32 10.23.23.2 0 0 65222 i
*> 10.2.2.1/32 10.23.23.2 0 0 65222 i
*> 10.2.2.2/32 10.23.23.2 0 0 65222 i
*> 10.2.2.3/32 10.23.23.2 0 0 65222 i
檢查rtr3上的BGP配置。
rtr3#show run | section router bgp
router bgp 65333
aggregate-address 10.0.0.0 255.0.0.0 suppress-map SUPPRESS-RTR2
neighbor 10.13.13.1 remote-as 65111
neighbor 10.23.23.2 remote-as 65222
neighbor 10.34.34.4 remote-as 65444
rtr3#
檢驗配置的路由對映。
rtr3#show route-map SUPPRESS-RTR2
route-map SUPPRESS-RTR2, permit, sequence 10
Match clauses:
ip address prefix-lists: suppress-rtr2
Set clauses:
Policy routing matches: 0 packets, 0 bytes
檢查配置的字首清單。
rtr3#show ip prefix-list suppress-rtr2
ip prefix-list suppress-rtr2: 1 entries
seq 5 permit 10.2.2.0/24
rtr3#
本範例中的首碼清單完全符合10.2.2.0首碼,這就是為什麼不會取消更具體的字首。必須使用小於或等於運算子來匹配更具體的字首。
更正字首清單的配置。
rtr3#configure terminal
rtr3(config)#no ip prefix-list suppress-rtr2
rtr3(config)#ip prefix-list suppress-rtr2 permit 10.2.2.0/24 le 32
rtr3(config)#end
rtr3#
這是正確配置prefix-list suppress-rtr2之後的rtr3 BGP表。
rtr3#show ip bgp
BGP table version is 14, local router ID is 10.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path, L long-lived-stale,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.0.0.0 0.0.0.0 32768 i
*> 10.1.1.0/32 10.13.13.1 0 0 65111 i
*> 10.1.1.1/32 10.13.13.1 0 0 65111 i
*> 10.1.1.2/32 10.13.13.1 0 0 65111 i
*> 10.1.1.3/32 10.13.13.1 0 0 65111 i
s> 10.2.2.0/32 10.23.23.2 0 0 65222 i
s> 10.2.2.1/32 10.23.23.2 0 0 65222 i
s> 10.2.2.2/32 10.23.23.2 0 0 65222 i
s> 10.2.2.3/32 10.23.23.2 0 0 65222 i
您已經學習了如何使用BGP可選引數來配置聚合路由,另外還為您提供兩個典型示例,可導致路由聚合失敗。這些是在配置中可以發現的最常見錯誤。如果在生成聚合路由時出現問題,並且無法發現有問題的配置,請使用debug ip bgp update命令收集更具體的詳細資訊。
| 修訂 | 發佈日期 | 意見 |
|---|---|---|
1.0 |
22-Jun-2026
|
初始版本 |