本文档介绍如何使用可选参数配置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的前缀不会被抑制,也不会生成聚合路由。
使用路由映射配置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),并且您正在设置no-export已知社区。由于使用了summary-only参数,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)上的信息。例如,只有摘要、摘要以及所有特定前缀、摘要和仅一些特定前缀等等。您可以主要使用以下命令:
有关详细信息,请参阅故障排除场景。
未收到汇总路由,仍可以看到特定前缀。
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
“抑制映射”(Suppress Map)配置为抑制范围,但不会抑制任何内容。
以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
|
初始版本 |