BGP路由的手动汇总

本文深入探讨了BGP路由聚合的配置细节,包括as-set属性的使用,以保留原路由的AS路径信息;advertise-map的应用,仅对匹配的路由进行聚合;attribute-map的介绍,用于清除聚合后路由的原有属性;以及suppress-map的设置,使某些路由条目在BGP路由表中标记为抑制状态。此外,文章还提供了多个路由器的配置实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

网络拓扑

XRV1

==========================================================

!
hostname XRV1
!
interface Loopback0
ip address 220.198.32.1 255.255.255.255
ip router isis 100
!
interface GigabitEthernet1
ip address 123.103.15.1 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
interface GigabitEthernet2
ip address 123.103.15.5 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
interface GigabitEthernet3
ip address 10.10.1.2 255.255.255.252
ip router isis 100
negotiation auto
isis circuit-type level-2-only
!
router isis 100
net 49.0000.2201.9832.1000.00
is-type level-2-only
!
router bgp 4809
bgp router-id 220.198.32.1
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
aggregate-address 43.180.0.0 255.255.0.0 as-set
aggregate-address 36.159.0.0 255.255.0.0 as-set
aggregate-address 27.160.0.0 255.255.0.0 as-set
aggregate-address 14.102.0.0 255.255.0.0 as-set
neighbor 123.103.15.2 remote-as 9308
neighbor 123.103.15.2 password cisco
neighbor 123.103.15.2 fall-over bfd
neighbor 123.103.15.6 remote-as 9808
neighbor 123.103.15.6 password cisco
neighbor 123.103.15.6 fall-over bfd
neighbor 220.198.32.5 remote-as 4809
neighbor 220.198.32.5 password cisco
neighbor 220.198.32.5 update-source Loopback0
neighbor 220.198.32.5 next-hop-self
!

XRV2

==========================================================

!
hostname XRV2
!
interface Loopback0
ip address 220.198.32.2 255.255.255.255
!
interface GigabitEthernet1
ip address 123.103.15.2 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
interface GigabitEthernet2
ip address 123.103.15.13 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
interface GigabitEthernet3
ip address 123.103.15.9 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
router bgp 9308
bgp router-id 220.198.32.2
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
aggregate-address 43.180.0.0 255.255.0.0 summary-only
aggregate-address 36.159.0.0 255.255.0.0 summary-only
aggregate-address 27.160.0.0 255.255.0.0 summary-only
aggregate-address 14.102.0.0 255.255.0.0 summary-only
neighbor 123.103.15.1 remote-as 4809
neighbor 123.103.15.1 password cisco
neighbor 123.103.15.1 fall-over bfd
neighbor 123.103.15.10 remote-as 9808
neighbor 123.103.15.10 password cisco
neighbor 123.103.15.10 fall-over bfd
neighbor 123.103.15.14 remote-as 4807
neighbor 123.103.15.14 password cisco
neighbor 123.103.15.14 fall-over bfd
!

XRV3

==========================================================

!
hostname XRV3
interface Loopback0
ip address 220.198.32.3 255.255.255.255
!
interface GigabitEthernet2
ip address 123.103.15.14 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
interface GigabitEthernet4
ip address 123.103.15.17 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
router bgp 4807
bgp router-id 220.198.32.3
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
neighbor 123.103.15.13 remote-as 9308
neighbor 123.103.15.13 password cisco
neighbor 123.103.15.13 fall-over bfd
neighbor 123.103.15.18 remote-as 9808
neighbor 123.103.15.18 password cisco
neighbor 123.103.15.18 fall-over bfd
!

XRV4

==========================================================

!
hostname XRV4
!
interface Loopback0
ip address 220.198.32.4 255.255.255.255
!
interface GigabitEthernet2
ip address 123.103.15.6 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
interface GigabitEthernet3
ip address 123.103.15.10 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
interface GigabitEthernet4
ip address 123.103.15.18 255.255.255.252
negotiation auto
bfd interval 250 min_rx 250 multiplier 3
!
router bgp 9808
bgp router-id 220.198.32.4
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
aggregate-address 43.180.0.0 255.255.0.0 suppress-map external-export
aggregate-address 27.160.0.0 255.255.0.0 suppress-map external-export
aggregate-address 14.102.0.0 255.255.0.0 suppress-map external-export
neighbor 123.103.15.5 remote-as 4809
neighbor 123.103.15.5 password cisco
neighbor 123.103.15.5 fall-over bfd
neighbor 123.103.15.9 remote-as 9308
neighbor 123.103.15.9 password cisco
neighbor 123.103.15.9 fall-over bfd
neighbor 123.103.15.17 remote-as 4807
neighbor 123.103.15.17 password cisco
neighbor 123.103.15.17 fall-over bfd
!
ip prefix-list external-export seq 5 permit 14.102.0.0/16
ip prefix-list external-export seq 10 permit 27.160.0.0/16
ip prefix-list external-export seq 15 permit 43.180.0.0/16
!
route-map external-export permit 10
match ip address prefix-list external-export
!

XRV5

==========================================================

!
hostname XRV5
!
interface Loopback0
ip address 220.198.32.5 255.255.255.255
ip router isis 100
!
interface GigabitEthernet0/0
switchport access vlan 100
switchport mode access
media-type rj45
negotiation auto
!
interface GigabitEthernet0/1
switchport trunk encapsulation dot1q
switchport mode trunk
media-type rj45
negotiation auto
!
interface GigabitEthernet0/2
media-type rj45
negotiation auto
!
interface GigabitEthernet0/3
media-type rj45
negotiation auto
!
interface Vlan1
ip address 14.102.1.254 255.255.255.0
!
interface Vlan2
ip address 14.102.128.254 255.255.255.0
!
interface Vlan3
ip address 14.102.192.254 255.255.255.0
!
interface Vlan4
ip address 14.102.255.254 255.255.255.0
!
interface Vlan5
ip address 27.160.1.254 255.255.255.0
!
interface Vlan6
ip address 27.160.128.254 255.255.255.0
!
interface Vlan7
ip address 27.160.192.254 255.255.255.0
!
interface Vlan8
ip address 27.160.255.254 255.255.255.0
!
interface Vlan9
ip address 36.159.1.254 255.255.255.0
!
interface Vlan10
ip address 36.159.128.254 255.255.255.0
!
interface Vlan11
ip address 36.159.192.254 255.255.255.0
!
interface Vlan12
ip address 36.159.255.254 255.255.255.0
!
interface Vlan13
ip address 43.180.1.254 255.255.255.0
!
interface Vlan14
ip address 43.180.128.254 255.255.255.0
!
interface Vlan15
ip address 43.180.192.254 255.255.255.0
!
interface Vlan16
ip address 43.180.255.254 255.255.255.0
!
interface Vlan100
ip address 10.10.1.1 255.255.255.252
ip router isis 100
isis circuit-type level-2-only
!
router isis 100
net 49.0000.2201.9832.5000.00
is-type level-2-only
!
router bgp 4809
bgp router-id 220.198.32.5
bgp log-neighbor-changes
bgp graceful-restart restart-time 120
bgp graceful-restart stalepath-time 360
bgp graceful-restart
network 14.102.1.0 mask 255.255.255.0
network 14.102.128.0 mask 255.255.255.0
network 14.102.192.0 mask 255.255.255.0
network 14.102.255.0 mask 255.255.255.0
network 27.160.1.0 mask 255.255.255.0
network 27.160.128.0 mask 255.255.255.0
network 27.160.192.0 mask 255.255.255.0
network 27.160.255.0 mask 255.255.255.0
network 36.159.1.0 mask 255.255.255.0
network 36.159.128.0 mask 255.255.255.0
network 36.159.192.0 mask 255.255.255.0
network 36.159.255.0 mask 255.255.255.0
network 43.180.1.0 mask 255.255.255.0
network 43.180.128.0 mask 255.255.255.0
network 43.180.192.0 mask 255.255.255.0
network 43.180.255.0 mask 255.255.255.0
neighbor 220.198.32.1 remote-as 4809
neighbor 220.198.32.1 password cisco
neighbor 220.198.32.1 update-source Loopback0
!

手工汇总的注意事项:

1.as-set 当BGP的路由汇总后,原路由的属性会丢失,比如as-path等,加as-set属性能够重新生成新的as-path

2. advertise-map 只对 advertise-map 匹配的路由条目进行路由聚合

3. attribute-map 聚合后清除原路由的属性

4.suppress-map 设置为bgp路由条目为suppress,即该条目在BGP路由表中带s

转载于:https://www.cnblogs.com/networking/p/10811510.html

<think>嗯,用户想了解在BGP中如何配置和发布汇总路由,还希望有示例。首先,我需要回忆一下BGP汇总路由的基本概念。BGP汇总路由通常通过手动聚合来实现,也就是使用静态路由汇总后再注入BGP,或者使用BGP的aggregate-address命令。不过不同厂商的设备配置可能不同,比如Cisco和华为的命令就有区别,用户可能需要具体的设备示例。 接下来,我得考虑用户可能的场景。用户可能是网络管理员,需要在多分支或大型网络中优化路由表,减少传播的路由条目,所以汇总路由是关键。用户可能还关心配置时的注意事项,比如避免路由环路,确保汇总路由的稳定性。 然后,我需要确保配置步骤的正确性。比如在Cisco设备中使用aggregate-address命令时,是否需要指定summary-only来抑制明细路由,或者是否需要生成AS_SET路径信息。同时,静态汇总后通过network命令发布,这也是常见的方法,但要注意静态路由的存在性。 另外,华为设备的配置可能不同,使用aggregate命令并指定不同的参数,比如detail-suppressed。用户可能需要跨厂商的示例,所以应该涵盖主流厂商的配置方法。 还要考虑可能的问题,比如汇总路由的条件,比如明细路由必须存在于BGP表中才能生成汇总路由。此外,配置汇总路由时是否需要调整路由策略,比如路由映射或社区属性。 最后,用户可能需要相关的问题,比如汇总路由不生效的原因,如何验证配置是否成功,或者如何选择手动汇总和自动汇总的区别。这些问题可以作为后续的扩展问题,帮助用户更全面地理解。</think>### BGP配置和发布汇总路由的方法 在BGP中,汇总路由(Route Aggregation)通过将多个明细路由合并为一条更宽泛的路由,减少路由表规模并提高网络稳定性。以下是配置和发布汇总路由的典型方法及示例: --- #### **1. 静态路由汇总后注入BGP** **步骤**: 1. 手动创建静态汇总路由; 2. 使用`network`命令将汇总路由发布到BGP中。 **示例(Cisco设备)**: ```plaintext ! 创建静态汇总路由 ip route 192.168.0.0 255.255.0.0 Null0 ! BGP配置 router bgp 65001 network 192.168.0.0 mask 255.255.0.0 ``` *说明*:静态路由指向`Null0`接口以避免环路,BGP通过`network`发布汇总路由[^1]。 --- #### **2. 使用BGP的`aggregate-address`命令** **步骤**: 1. 确保明细路由已存在于BGP表中; 2. 通过`aggregate-address`生成汇总路由。 **示例(Cisco设备)**: ```plaintext router bgp 65001 aggregate-address 192.168.0.0 255.255.0.0 summary-only ``` *参数说明*: - `summary-only`:抑制明细路由的发布,仅通告汇总路由- 若省略该参数,则同时发布明细和汇总路由[^2]。 --- #### **3. 华为设备配置示例** ```plaintext bgp 65001 aggregate 192.168.0.0 255.255.0.0 detail-suppressed ``` *说明*:`detail-suppressed`等效于Cisco的`summary-only`,用于抑制明细路由[^3]。 --- #### **关键注意事项** 1. **明细路由必须存在**:BGP需先学习到明细路由才能生成汇总; 2. **路径属性继承**:默认汇总路由的AS_PATH会被简化,可通过`as-set`保留原始AS_PATH信息(如`aggregate-address 192.168.0.0 255.255.0.0 as-set`); 3. **策略控制**:通过路由策略(Route-map)为汇总路由添加社区属性或调整优先级。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值