可选 BGP 配置
本节介绍可选配置。本节提供的步骤假设您已按照基本 BGP 配置中的描述配置了基本 BGP。
对等组
您可以定义一个或多个对等组,并将该对等会话的所有通用属性关联到一个对等组,而不是指定每个单独对等方的属性。您只需将对等方附加到一个对等组一次;然后它将继承为该对等组激活的所有地址族。
如果要添加到组的对等方已存在于 BGP 配置中,请先删除它,然后再将其添加到对等组。
以下示例命令创建一个名为 SPINE 的对等组,其中包含两个外部对等方。
cumulus@leaf01:~$ nv set vrf default router bgp peer-group SPINE
cumulus@leaf01:~$ nv set vrf default router bgp peer-group SPINE remote-as external
cumulus@leaf01:~$ nv set vrf default router bgp neighbor 10.0.1.0 peer-group SPINE
cumulus@leaf01:~$ nv set vrf default router bgp neighbor 10.0.1.12 peer-group SPINE
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor SPINE peer-group
leaf01(config-router)# neighbor SPINE remote-as external
leaf01(config-router)# neighbor 10.0.1.0 peer-group SPINE
leaf01(config-router)# neighbor 10.0.1.12 peer-group SPINE
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
cumulus@leaf01:~$
对于未编号的配置,您可以使用单个命令来配置邻居并将其附加到对等组。
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 peer-group SPINE
leaf01(config-router)# neighbor swp51 interface peer-group SPINE
如果取消设置对等组,请确保它未应用于任何邻居。如果对等组应用于邻居,请在删除对等组之前,直接在邻居上配置所有参数,例如远程 AS。
BGP 动态邻居
BGP 动态邻居为 BGP 对等组的指定 IPv4 或 IPv6 地址范围内的远程邻居提供 BGP 对等连接。您可以将每个范围配置为子网 IP 地址。
配置动态邻居后,BGP 扬声器可以侦听 IP 地址范围内且映射到对等组的任何邻居,并与之建立对等关系。您还可以限制动态对等方的数量。默认值为 100。
以下示例命令为对等组 SPINE 配置与地址范围 10.0.1.0/24 内的远程邻居的 BGP 对等连接,并将动态对等方的数量限制为 5。
对等组必须已存在,否则配置将不适用。
cumulus@leaf01:~$ nv set vrf default router bgp dynamic-neighbor listen-range 10.0.1.0/24 peer-group SPINE
cumulus@leaf01:~$ nv set vrf default router bgp dynamic-neighbor limit 5
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# bgp listen range 10.0.1.0/24 peer-group SPINE
leaf01(config-router)# bgp listen limit 5
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
cumulus@leaf01:~$
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
router bgp 65101
neighbor SPINE peer-group
neighbor SPINE remote-as external
bgp listen limit 5
bgp listen range 10.0.1.0/24 peer-group SPINE
eBGP 多跳
eBGP 多跳选项允许您使用 BGP 与距离超过一跳的外部对等方交换路由。
以下示例命令配置 Cumulus Linux 以在两个未直接连接的 eBGP 对等方之间建立连接,并将用于到达 eBGP 对等方的最大跳数设置为 1。
cumulus@leaf01:~$ nv set vrf default router bgp neighbor 10.10.10.101 remote-as external
cumulus@leaf01:~$ nv set vrf default router bgp neighbor 10.10.10.101 multihop-ttl 1
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor 10.10.10.101 remote-as external
leaf01(config-router)# neighbor 10.10.10.101 ebgp-multihop
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
BGP TTL 安全跳数
您可以使用 TTL 安全跳数选项来防止针对 eBGP 的攻击,例如拒绝服务 (DoS) 攻击。默认情况下,发送到 eBGP 邻居的 BGP 消息的 IP 生存时间 (TTL) 为 1,这要求对等方直接连接,否则,数据包将在途中过期。您可以使用 eBGP 多跳选项调整 TTL。攻击者可以调整数据包的 TTL,使其看起来像是来自直接连接的对等方。
BGP TTL 安全跳数选项反转 BGP 计算 TTL 的方向。Cumulus Linux 不仅接受 TTL 为 1 的数据包,还接受 TTL 大于或等于 255 减去指定跳数的 BGP 消息。
当您使用 TTL 安全时,您不需要 eBGP 多跳。
以下命令示例将 TTL 安全跳数值设置为 200
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 ttl-security hops 200
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor swp51 ttl-security hops 200
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65101
...
neighbor swp51 ttl-security hops 200
...
- 当您在对等组而不是特定邻居上配置
ttl-security hops
时,FRR 不会将其添加到运行配置或/etc/frr/frr.conf
文件中。要解决此问题,请将ttl-security hops
添加到各个邻居而不是对等组。 - 启用
ttl-security hops
不会使用相关信息对硬件进行编程。Cumulus Linux 将帧转发到 CPU,然后将其丢弃。使用 NVUE 命令显式地将相关条目添加到硬件。有关 ACL 的更多信息,请参阅 访问控制列表。
启用 MD5 的 BGP 邻居
您可以对 BGP 对等连接进行身份验证,以防止干扰您的路由表。
要为 BGP 对等方启用 MD5 身份验证,请在每个对等方上设置相同的密码。
以下示例命令在 BGP 对等方 leaf01 和 spine01 上设置密码 mypassword
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 password mypassword
cumulus@leaf01:~$ nv config apply
cumulus@spine01:~$ nv set vrf default router bgp neighbor swp1 password mypassword
cumulus@spine01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor swp51 password mypassword
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
cumulus@spine01:~$ sudo vtysh
...
spine01# configure terminal
spine01(config)# router bgp 65199
spine01(config-router)# neighbor swp1 password mypassword
spine01(config-router)# end
spine01# write memory
spine01# exit
您可以使用 NVUE nv show vrf default router bgp neighbor <neighbor>
命令或 vtysh show ip bgp neighbor <neighbor>
命令确认配置。
Cumulus Linux 不强制执行针对 BGP 侦听范围对等组(用于接受和创建动态 BGP 邻居)配置的 MD5 密码,并接受来自未指定密码的对等方的连接。
删除私有 BGP ASN
如果您在数据中心中使用私有 ASN,则通告给邻居的路由将包含您的私有 ASN。以下示例说明如何从路由中删除私有 ASN 以及如何将私有 ASN 替换为您的公共 ASN。
以下示例命令从通告给 swp51(未编号接口)上邻居的路由中删除私有 ASN
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath private-as remove
cumulus@leaf01:~$ nv config apply
您可以使用以下命令将私有 ASN 替换为您的公共 ASN
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath replace-peer-as on
cumulus@leaf01:~$ nv config apply
要取消设置上述配置
cumulus@leaf01:~$ nv unset vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath private-as remove
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ nv unset vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath replace-peer-as on
cumulus@leaf01:~$ nv config apply
将行 neighbor swp51 remove-private-AS
添加到 address-family ipv4 unicast 节
cumulus@leaf01:~$ sudo nano /etc/frr/frr.conf
...
router bgp 65101
bgp router-id 10.10.10.1
neighbor underlay peer-group
neighbor underlay remote-as external
neighbor swp51 interface peer-group underlay
neighbor swp52 interface peer-group underlay
neighbor swp53 interface peer-group underlay
neighbor swp54 interface peer-group underlay
!
address-family ipv4 unicast
redistribute connected
neighbor swp51 remove-private-AS
exit-address-family
!
...
多个 BGP ASN
Cumulus Linux 支持为不同的 VRF 实例使用不同的 ASN。
以下示例配置 border01 上的 VRF RED 和 VRF BLUE,以分别对 fw1 和 fw2 使用 ASN 65532 和 65533

cumulus@border01:~$ nv set vrf RED router bgp autonomous-system 65532
cumulus@border01:~$ nv set vrf RED router bgp router-id 10.10.10.63
cumulus@border01:~$ nv set vrf RED router bgp neighbor swp3 remote-as external
cumulus@border01:~$ nv set vrf BLUE router bgp autonomous-system 65533
cumulus@border01:~$ nv set vrf BLUE router bgp router-id 10.10.10.63
cumulus@border01:~$ nv set vrf BLUE router bgp neighbor swp4 remote-as external
cumulus@border01:~$ nv config apply
cumulus@border01:~$ sudo vtysh
...
border01# configure terminal
border01(config)# router bgp 65532 vrf RED
border01(config-router)# bgp router-id 10.10.10.63
border01(config-router)# neighbor swp3 interface remote-as external
border01(config-router)# exit
border01(config)# router bgp 65533 vrf BLUE
border01(config-router)# bgp router-id 10.10.10.63
border01(config-router)# neighbor swp4 interface remote-as external
border01(config-router)# end
border01# write memory
border01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中
cumulus@border01:~$ cat /etc/frr/frr.conf
...
log syslog informational
!
vrf RED
vni 4001
vrf BLUE
vni 4002
!
router bgp 65132
bgp router-id 10.10.10.63
bgp bestpath as-path multipath-relax
neighbor underlay peer-group
neighbor underlay remote-as external
neighbor peerlink.4094 interface remote-as internal
neighbor swp51 interface peer-group underlay
neighbor swp52 interface peer-group underlay
!
address-family ipv4 unicast
redistribute connected
exit-address-family
!
address-family l2vpn evpn
neighbor underlay activate
advertise-all-vni
exit-address-family
!
router bgp 65532 vrf RED
bgp router-id 10.10.10.63
neighbor swp3 remote-as external
!
address-family ipv4 unicast
redistribute static
exit-address-family
!
address-family l2vpn evpn
neighbor underlay activate
advertise-all-vni
exit-address-family
!
router bgp 65533 vrf BLUE
bgp router-id 10.10.10.63
neighbor swp4 remote-as external
!
address-family ipv4 unicast
redistribute static
exit-address-family
!
address-family l2vpn evpn
neighbor underlay activate
advertise-all-vni
exit-address-family
!
line vty
使用上述配置,vtysh show ip bgp vrf RED summary
命令输出显示本地 ASN 为 65532。
cumulus@border01:mgmt:~$ sudo vtysh
...
border01# show ip bgp vrf RED summary
ipv4 unicast summary
BGP router identifier 10.10.10.63, local AS number 65532 vrf-id 35
BGP table version 1
RIB entries 1, using 192 bytes of memory
Peers 1, using 21 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt
fw1(swp3) 4 65199 2015 2015 0 0 0 01:40:36 1 1
Total number of neighbors 1
...
vtysh show ip bgp summary
命令显示全局表,其中本地 ASN 65132 与 spine01 对等。
cumulus@border01:mgmt:~$ sudo vtysh
...
leaf01# show ip bgp summary
ipv4 unicast summary
BGP router identifier 10.10.10.63, local AS number 65132 vrf-id 0
BGP table version 3
RIB entries 5, using 960 bytes of memory
Peers 1, using 43 KiB of memory
Peer groups 1, using 64 bytes of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt
spine01(swp51) 4 65199 2223 2223 0 0 0 01:50:18 1 3
Total number of neighbors 1
...
BGP allowas-in
为防止环路,如果交换机在其 AS 路径中看到自己的 ASN,则会自动丢弃 BGP 网络前缀。但是,您可以配置 Cumulus Linux 即使在 AS 路径中检测到自己的 ASN (allowas-in) 也接收和处理路由。
要启用 allowas-in
cumulus@switch:~$ nv set vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath allow-my-asn enable on
cumulus@switch:~$ nv config apply
要禁用 allowas-in,请运行 nv unset
命令
cumulus@switch:~$ nv unset vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath allow-my-asn enable on
cumulus@switch:~$ nv config apply
cumulus@switch:~$ sudo vtysh
...
switch# configure terminal
switch(config)# router bgp 65101
switch(config-router)# address-family ipv4 unicast
switch(config-router-af)# neighbor swp51 allowas-in
switch(config-router-af)# end
switch# write memory
switch# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件的 address-family
节中。例如
...
address-family ipv4 unicast
network 10.10.10.1/32
redistribute connected
neighbor swp51 allowas-in
...
您可以配置其他选项
- 您可以设置接收到的 AS 路径中本地系统 AS 号的最大出现次数
- 您可以允许接收到的 AS 路径包含本地系统的 ASN,但前提是它是源 AS
以下示例将接收到的 AS 路径中本地系统 AS 号的最大出现次数设置为 4
cumulus@switch:~$ nv set vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath allow-my-asn occurrences 4
cumulus@switch:~$ nv config apply
要取消设置上述配置,请运行 nv unset
命令
cumulus@switch:~$ nv unset vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath allow-my-asn occurrences 4
cumulus@switch:~$ nv config apply
cumulus@switch:~$ sudo vtysh
...
switch# configure terminal
switch(config)# router bgp 65101
switch(config-router)# address-family ipv4 unicast
switch(config-router-af)# neighbor swp51 allowas-in 4
switch(config-router-af)# end
switch# write memory
switch# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件的 address-family
节中。例如
...
address-family ipv4 unicast
network 10.10.10.1/32
redistribute connected
neighbor swp51 allowas-in 4
...
以下示例允许接收到的 AS 路径包含本地系统的 ASN,但前提是它是源 AS
cumulus@switch:~$ nv set vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath allow-my-asn origin on
cumulus@switch:~$ nv config apply
要取消设置上述配置,请运行 nv unset
命令
cumulus@switch:~$ nv unset vrf default router bgp neighbor swp51 address-family ipv4-unicast aspath allow-my-asn origin on
cumulus@switch:~$ nv config apply
cumulus@switch:~$ sudo vtysh
...
switch# configure terminal
switch(config)# router bgp 65101
switch(config-router)# address-family ipv4 unicast
switch(config-router-af)# neighbor swp51 allowas-in origin
switch(config-router-af)# end
switch# write memory
switch# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件的 address-family
节中。例如
...
address-family ipv4 unicast
network 10.10.10.1/32
redistribute connected
neighbor swp51 allowas-in origin
...
更新源
您可以配置 BGP 在与邻居交换 BGP 更新时使用特定的 IP 地址。例如,在编号的 BGP 配置中,您可以将源 IP 地址设置为交换机的环回地址。
cumulus@leaf01:~$ nv set vrf default router bgp neighbor 10.10.10.10 update-source 10.10.10.1
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor 10.10.10.10 update-source 10.10.10.1
leaf01(config-router-af)# end
leaf01# write memory
leaf01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65101
bgp router-id 10.10.10.1
neighbor 10.10.10.10 remote-as 65000
neighbor 10.10.10.10 update-source 10.10.10.1
...
ECMP
BGP 支持等价多路径 (ECMP)。如果 BGP 节点从多个对等方听到某个前缀,它将拥有必要的信息来编程路由表并通过所有这些对等方转发该前缀的流量。BGP 通常为每个前缀选择一条最佳路径,并将该路由安装在转发表中。
Cumulus Linux 默认启用 BGP 多路径选项,并将最大路径数设置为 64,以便交换机可以将多条等价 BGP 路径安装到转发表中,并在多条链路之间进行负载均衡。您可以根据需要更改允许的路径数。
示例命令将最大路径数更改为 120。您可以设置介于 1 到 256 之间的值。1 禁用 BGP 多路径选项。
cumulus@switch:~$ nv set vrf default router bgp address-family ipv4-unicast multipaths ibgp 120
cumulus@switch:~$ nv config apply
cumulus@switch:~$ sudo vtysh
...
switch# configure terminal
switch(config)# router bgp 65101
switch(config-router)# address-family ipv4
switch(config-router-af)# maximum-paths 120
switch(config-router-af)# end
switch# write memory
switch# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件的 address-family
节中。例如
...
address-family ipv4 unicast
network 10.1.10.0/24
network 10.10.10.1/32
maximum-paths 120
exit-address-family
...
当您启用 BGP 多路径时,Cumulus Linux 会对来自同一 AS 的 BGP 路由进行负载均衡。如果路由跨越多个不同的 AS 邻居,即使 AS 路径长度相同,也不会进行负载均衡。要在从不同 AS 邻居接收到的多条路径之间进行负载均衡:
cumulus@switch:~$ nv set vrf default router bgp path-selection multipath aspath-ignore on
cumulus@switch:~$ nv config apply
cumulus@switch:~$ sudo vtysh
...
switch# configure terminal
switch(config)# router bgp 65101
switch(config-router)# bgp bestpath as-path multipath-relax
switch(config-router)# end
switch# write memory
switch# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65101
bgp router-id 10.0.0.1
bgp bestpath as-path multipath-relax
...
当您禁用 bestpath as-path multipath-relax 选项时,EVPN 类型 5 路由不使用更新的配置。类型 5 路由继续使用底层结构中的所有可用 ECMP 路径,而与 ASN 无关。
通告具有 IPv6 下一跳的 IPv4 前缀
RFC 5549 定义了 BGP 如何通告具有 IPv6 下一跳的 IPv4 前缀。RFC 未区分 IPv6 对等连接和下一跳值是必须是全局单播地址 (GUA) 还是链路本地地址。Cumulus Linux 支持使用 IPv6 全局单播和链路本地下一跳地址通告 IPv4 前缀,无论使用未编号还是编号 BGP。
当 BGP 对等连接使用 IPv6 全局地址,并且 BGP 通告和安装 IPv4 前缀时,Cumulus Linux 使用 IPv6 路由通告来派生对等方的 MAC 地址,以便 FRR 可以创建具有链路本地 IPv4 下一跳地址(由 RFC 3927 定义)的 IPv4 路由。FRR 在收到来自 BGP 对等方的更新后,会自动配置这些路由通告设置,该 BGP 对等方使用具有 IPv4 前缀和 IPv6 下一跳的 IPv6 全局地址,并在协商增强的下一跳功能后。
要启用通过全局 IPv6 对等连接通告具有 IPv6 下一跳的 IPv4 前缀,请将 extended-nexthop
功能添加到 BGP 会话每一端的全局 IPv6 邻居语句。
cumulus@switch:~$ nv set vrf default router bgp neighbor 2001:db8:0002::0a00:0002 capabilities extended-nexthop on
cumulus@switch:~$ nv config apply
cumulus@switch:~$ sudo vtysh
...
switch# configure terminal
switch(config)# router bgp 65101
switch(config-router)# neighbor 2001:db8:0002::0a00:0002 capability extended-nexthop
switch(config-router)# end
switch# write memory
switch# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65101
...
neighbor 2001:db8:0002::0a00:0002 capability extended-nexthop
...
确保您已在 IPv4 单播地址族下激活 IPv6 对等方;否则,所有对等方默认在 IPv4 单播地址族中激活。如果您配置 no bgp default ipv4-unicast
,则需要如下所示在 IPv4 单播地址族下激活 IPv6 邻居
cumulus@switch:~$ nv set vrf default router bgp neighbor 2001:db8:0002::0a00:0002 capabilities extended-nexthop on
cumulus@switch:~$ nv set vrf default router bgp neighbor 2001:db8:0002::0a00:0002 address-family ipv4-unicast enable on
cumulus@switch:~$ nv config apply
cumulus@switch:~$ sudo vtysh
...
switch# configure terminal
switch(config)# router bgp 65101
switch(config-router)# neighbor 2001:db8:0002::0a00:0002 capability extended-nexthop
switch(config-router)# address-family ipv4 unicast
switch(config-router-af)# neighbor 2001:db8:0002::0a00:0002 activate
switch(config-router-af)# end
switch# write memory
switch# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65101
router-id 10.10.10.1
no bgp default ipv4-unicast
neighbor 2001:db8:0002::0a00:0002 remote-as external
neighbor 2001:db8:0002::0a00:0002 capability extended-nexthop
!
address-family ipv4 unicast
neighbor 2001:db8:0002::0a00:0002 activate
exit-address-family
...
邻居最大前缀数
为防止 BGP 导致内部网络连接中断,您可以控制要从 BGP 邻居接收的路由通告(前缀)数量。
以下示例命令将允许从 swp51 上的 BGP 邻居接收的最大前缀数设置为 3000
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 address-family ipv4-unicast prefix-limits inbound maximum 3000
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65001
leaf01(config-router)# neighbor swp51 maximum-prefix 3000
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
聚合地址
为了最大限度地减小路由表的大小并节省带宽,您可以将路由表中的一系列网络聚合为单个前缀。
以下示例命令将一系列地址(例如 10.1.1.0/24、10.1.2.0/24、10.1.3.0/24)聚合为单个前缀 10.1.0.0/16
cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv4-unicast aggregate-route 10.1.0.0/16
cumulus@leaf01:~$ nv config apply
summary-only
选项确保 BGP 在发送更新之前抑制聚合地址内较长的前缀
cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv4-unicast aggregate-route 10.1.0.0/16 summary-only on
cumulus@leaf01:~$ nv config apply
抑制路由通告
您可以配置 BGP 等待来自 RIB 的响应,指示安装在 RIB 中的路由也已安装在 ASIC 中,然后再向对等方发送更新。
cumulus@leaf01:~$ nv set router bgp wait-for-install on
cumulus@leaf01:~$ nv config apply
当您配置抑制路由通告时,NVUE 会重新加载 switchd
。
运行以下 vtysh 命令
cumulus@leaf01:~$ sudo vtysh ... leaf01# configure terminal leaf01(config)# router bgp 65101 leaf01(config-router)# bgp suppress-fib-pending leaf01(config-router)# end leaf01# write memory leaf01# exit
vtysh 命令将配置保存在
/etc/frr/frr.conf
文件中。例如... router bgp 65199 bgp router-id 10.10.10.101 neighbor swp51 remote-as external bgp suppress-fib-pending ...
编辑
/etc/cumulus/switchd.d/kernel_route_offload_flags.conf
文件,将kernel_route_offload_flags
参数设置为 2cumulus@leaf01:~$ sudo nano /etc/cumulus/switchd.d/kernel_route_offload_flags.conf # Set routing-forwarding-sync mode for routes. # 0: No notification on HW install success or failure (default mode) # 1: Notify HW install failure # 2: Notify HW install success/failure kernel_route_offload_flags = 2
重启 switchd
cumulus@leaf01:~$ sudo systemctl restart switchd.service
ISSU 在升级或排除活动交换机故障时自动抑制路由通告,从而最大限度地减少对网络的干扰。
BGP add-path
Cumulus Linux 同时支持 BGP add-path RX 和 BGP add-path TX。
BGP add-path RX
BGP add-path RX 使 BGP 能够接收同一前缀的多条路径。路径标识符确保附加路径不会覆盖先前通告的路径。Cumulus Linux 默认启用 BGP add-path RX;您无需执行其他配置。
要查看现有功能,请运行 vtysh show ip bgp neighbors
命令。您可以在邻居功能下方的添加路径子节中看到现有功能。
以下示例输出显示 BGP 可以发送和接收附加的 BGP 路径,并且 swp51 上的 BGP 邻居同时支持这两者。
cumulus@leaf01:~$ sudo vtysh
...
leaf01# show ip bgp neighbors
BGP neighbor on swp51: fe80::7c41:fff:fe93:b711, remote AS 65199, local AS 65101, external link
Hostname: spine01
BGP version 4, remote router ID 10.10.10.101, local router ID 10.10.10.1
BGP state = Established, up for 1d12h39m
Last read 00:00:03, Last write 00:00:01
Hold time is 9, keepalive interval is 3 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
AddPath:
IPv4 Unicast: RX advertised IPv4 Unicast and received
Extended nexthop: advertised and received
Address families by peer:
IPv4 Unicast
Route refresh: advertised and received(old & new)
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: leaf01,domain name: n/a) received (name: spine01,domain name: n/a)
Graceful Restart Capability: advertised and received
...
要查看当前的附加路径,请运行 vtysh show ip bgp <prefix>
命令。示例输出显示 TX 节点为接收添加了一条附加路径。每条路径都有唯一的 AddPath ID。
cumulus@leaf01:mgmt:~$ sudo vtysh
...
leaf01# show ip bgp 10.10.10.9
BGP routing table entry for 10.10.10.9/32
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Advertised to non peer-group peers:
spine01(swp51) spine02(swp52)
65020 65012
fe80::4638:39ff:fe00:5c from spine01(swp51) (10.10.10.12)
(fe80::4638:39ff:fe00:5c) (used)
Origin incomplete, localpref 100, valid, external, multipath, bestpath-from-AS 65020, best (Older Path)
AddPath ID: RX 0, TX 6
Last update: Wed Nov 16 22:47:00 2016
65020 65012
fe80::4638:39ff:fe00:2b from spine02(swp52) (10.10.10.12)
(fe80::4638:39ff:fe00:2b) (used)
Origin incomplete, localpref 100, valid, external, multipath
AddPath ID: RX 0, TX 3
Last update: Fri Oct 2 03:56:33 2020
BGP add-path TX
BGP add-path TX 使 BGP 能够通告的不仅仅是前缀的最佳路径。Cumulus Linux 包括两个选项
addpath-tx-all-paths
将所有已知路径通告给邻居。addpath-tx-bestpath-per-AS
仅将从每个 AS 学习到的最佳路径通告给邻居。
以下示例命令配置 leaf01 将从每个 AS 学习到的最佳路径通告给 swp50 上的 BGP 邻居
cumulus@leaf01:~$ nv set vrf default router bgp autonomous-system 65101
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp50 address-family ipv4-unicast add-path-tx best-per-as
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor swp50 addpath-tx-bestpath-per-AS
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
以下示例命令配置 leaf01 将从每个 AS 学习到的所有路径通告给 swp50 上的 BGP 邻居
cumulus@leaf01:~$ nv set vrf default router bgp autonomous-system 65101
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp50 address-family ipv4-unicast add-path-tx all-paths
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor swp50 addpath-tx-all-paths
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
以下示例配置显示 BGP add-path TX 如何通告从每个 AS 学习到的最佳路径。
![]() | 在此配置中
|
当您在 leaf02 上运行 show ip bgp 10.10.10.3/32
命令时,命令输出显示 leaf03 环回 IP 地址和两条 BGP 路径,两条路径均来自 leaf01
cumulus@leaf02:mgmt:~$ sudo vtysh
...
leaf02# show ip bgp 10.10.10.3/32
BGP routing table entry for 10.10.10.3/32
Paths: (2 available, best #2, table default)
Advertised to non peer-group peers:
leaf01(swp50)
65101 65199 65103
fe80::4638:39ff:fe00:13 from leaf01(swp50) (10.10.10.1)
(fe80::4638:39ff:fe00:13) (used)
Origin IGP, valid, external
AddPath ID: RX 4, TX-All 0 TX-Best-Per-AS 0
Last update: Thu Oct 15 18:31:46 2020
65101 65198 65103
fe80::4638:39ff:fe00:13 from leaf01(swp50) (10.10.10.1)
(fe80::4638:39ff:fe00:13) (used)
Origin IGP, valid, external, bestpath-from-AS 65101, best (Nothing left to compare)
AddPath ID: RX 3, TX-All 0 TX-Best-Per-AS 0
Last update: Thu Oct 15 18:31:46 2020
条件通告
即使存在不同的路径,路由通常也会传播。BGP 条件通告功能允许您仅在其他路由存在或不存在时才通告某些路由。
此功能通常用于多宿主网络,其中 BGP 仅在来自另一提供商的信息不存在时才向其中一个提供商通告某些前缀。例如,多宿主路由器可以使用条件通告来选择哪个上游提供商了解其提供的路由,以便它可以影响哪个提供商处理发往下游路由器的流量。这对于服务成本、延迟或 BGP 中未原生考虑的其他策略要求非常有用。
条件通告使用 non-exist-map
或 exist-map
以及 advertise-map
关键字按路由前缀跟踪路由。您配置 BGP 邻居以使用路由图。
在大量 BGP 邻居上配置条件通告时,请务必小心。Cumulus Linux 默认每 60 秒扫描整个 RIB 表;根据 RIB 中的路由数量,这可能会导致更长的处理时间。NVIDIA 不建议您在超过 50 个邻居上配置条件通告。
以下示例命令配置交换机仅当路由表存在 10.0.0.0/24 路由时才发送 10.0.0.0/8 汇总路由。这些命令执行以下配置
- 启用条件通告选项。
- 创建名为 EXIST 的前缀列表,其中包含路由 10.0.0.0/24。
- 创建名为 EXISTMAP 的路由图,该路由图使用前缀列表 EXIST。您必须提供路由图匹配类型(
ipv4
或ipv6
)。 - 创建名为 ADVERTISE 的前缀列表,其中包含要通告的路由 (10.0.0.0/8)。
- 创建名为 ADVERTISEMAP 的路由图,该路由图使用前缀列表 ADVERTISE。您必须提供路由图匹配类型(
ipv4
或ipv6
)。 - 配置 BGP 邻居 swp51 以使用路由图。
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 address-family ipv4-unicast conditional-advertise enable on
cumulus@leaf01:~$ nv set router policy prefix-list EXIST rule 10 match 10.0.0.0/24
cumulus@leaf01:~$ nv set router policy prefix-list EXIST rule 10 action permit
cumulus@leaf01:~$ nv set router policy route-map EXISTMAP rule 10 match type ipv4
cumulus@leaf01:~$ nv set router policy route-map EXISTMAP rule 10 action permit
cumulus@leaf01:~$ nv set router policy route-map EXISTMAP rule 10 match ip-prefix-list EXIST
cumulus@leaf01:~$ nv set router policy prefix-list ADVERTISE rule 10 action permit
cumulus@leaf01:~$ nv set router policy prefix-list ADVERTISE rule 10 match 10.0.0.0/8
cumulus@leaf01:~$ nv set router policy route-map ADVERTISEMAP rule 10 match type ipv4
cumulus@leaf01:~$ nv set router policy route-map ADVERTISEMAP rule 10 action permit
cumulus@leaf01:~$ nv set router policy route-map ADVERTISEMAP rule 10 match ip-prefix-list ADVERTISE
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 address-family ipv4-unicast conditional-advertise advertise-map ADVERTISEMAP
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 address-family ipv4-unicast conditional-advertise exist-map EXIST
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# ip prefix-list EXIST seq 10 permit 10.0.0.0/24
leaf01(config)# route-map EXISTMAP permit 10
leaf01(config-route-map)# match ip address prefix-list EXIST
leaf01(config-route-map)# exit
leaf01(config)# ip prefix-list ADVERTISE seq 10 permit 10.0.0.0/8
leaf01(config)# route-map ADVERTISEMAP permit 10
leaf01(config-route-map)# match ip address prefix-list ADVERTISE
leaf01(config-route-map)# exit
leaf01(config)# router bgp
leaf01(config-router)# neighbor swp51 advertise-map ADVERTISEMAP exist-map EXISTMAP
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
这些命令将配置保存在 /etc/frr/frr.conf
文件中。例如
cumulus@leaf01:~$ sudo cat /etc/frr/frr.conf
...
neighbor swp51 activate
neighbor swp51 advertise-map ADVERTISEMAP exist-map EXIST
...
ip prefix-list ADVERTISE seq 10 permit 10.0.0.0/8
ip prefix-list EXIST seq 10 permit 10.0.0.0/24
route-map ADVERTISEMAP permit 10
match ip address prefix-list ADVERTISE
route-map EXISTMAP permit 10
match ip address prefix-list EXIST
Cumulus Linux 每 60 秒扫描整个 RIB 表。您可以设置条件通告计时器以增加或减少您希望 Cumulus Linux 扫描 RIB 表的频率。您可以设置介于 5 到 240 秒之间的值。
较低的值(例如 5)会增加所需的处理量。在大量 BGP 邻居上配置条件通告时,请务必小心。
cumulus@leaf01:~$ nv set vrf default router bgp timers conditional-advertise 100
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp
leaf01(config-router)# bgp conditional-advertisement timer 100
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
这些命令将配置保存在 /etc/frr/frr.conf
文件中。例如
cumulus@leaf01:~$ sudo cat /etc/frr/frr.conf
...
router bgp 65101
bgp router-id 10.10.10.1
bgp conditional-advertisement timer 100
neighbor swp51 interface remote-as external
neighbor swp51 advertisement-interval 0
neighbor swp51 timers 3 9
neighbor swp51 timers connect 10
neighbor swp52 interface remote-as external
neighbor swp52 advertisement-interval 0
neighbor swp52 timers 3 9
neighbor swp52 timers connect 10
...
下一跳跟踪
默认情况下,下一跳跟踪不会通过默认路由解析下一跳。如果您希望 BGP 跨默认路由对等,请运行 vtysh ip nht resolve-via-default
命令。
以下示例命令配置 BGP 从默认 VRF 跨默认路由对等。
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# ip nht resolve-via-default
leaf01(config)# exit
leaf01# write memory
leaf01# exit
以下示例命令配置 BGP 从 VRF BLUE 跨默认路由对等
cumulus@leaf01:~$ sudo vtysh
leaf01# configure terminal
leaf01(config)# vrf BLUE
leaf01(config-vrf)# ip nht resolve-via-default
leaf01(config-vrf)# end
leaf01# write memory
leaf01# exit
cumulus@leaf01:~$
BGP 前缀无关收敛
BGP 前缀无关收敛 (PIC) 缩短了收敛时间,并提高了远程链路和节点故障(当 BGP 下一跳失败时)的单播流量收敛速度,而与路由规模无关。远程链路是脊和远程叶子之间的链路,或脊和超级脊层之间的链路。
当您配置 BGP PIC 时,Cumulus Linux 为每个源分配一个下一跳组,远程叶子通告具有从路由器 ID 派生的前缀的路由。远程叶子使用路由源扩展社区 (SOO) 标记前缀路由,以便本地叶子识别路由。当网络拓扑更改时,本地叶子获取具有更新的 ECMP 的路由器 ID 路由,从而允许对来自远程叶子的所有前缀进行 O (1) 下一跳组替换操作,而无需等待单独的 BGP 更新。
- Cumulus Linux 在 Spectrum-4 交换机上支持 BGP PIC。
- Cumulus Linux 不支持将 BGP PIC 与 EVPN、MLAG 或 VRF 路由泄漏结合使用。
- 如果您已配置 EVPN,请勿配置 PIC。
- 您只能在默认 VRF 上配置 PIC。
- NVIDIA 建议您在启用 PIC 时不要将接口地址重新分发到 BGP 中。
- 请勿使用相同的值配置路由器 ID 和网络地址。
- BGP 路由器 ID 和聚合地址不得在同一子网中。
- 启用 PIC 时,请勿使用火星地址作为 BGP 路由器 ID。
- PIC 需要额外的 ECMP 硬件资源。请参阅 下一跳组的额外 ECMP 资源优化
要配置 PIC
- 仅在叶子上,启用 BGP advertise origin 选项,以便 BGP 可以将 SOO 扩展社区附加到从路由源发出的通告给其对等方的所有路由。
- 在所有交换机上,启用 BGP next hop group per source 选项,以便当 BGP 接收到带有 SOO 扩展社区的路由时,它会为每个源分配一个下一跳组。
- 在脊和超级脊上,将 只读模式 BGP 收敛等待时间设置为 30,将收敛等待建立等待时间设置为 15。这些是使用 PIC 时确保最佳收敛的最低建议计时器设置。
更改 BGP advertise origin 选项或 BGP next hop group per source 选项可能会导致流量中断。
在叶交换机上,启用 BGP 宣告源选项。以下示例为 IPv4 启用 BGP 宣告源选项
cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv4-unicast advertise-origin cumulus@leaf01:~$ nv config apply
对于 IPv6,运行
nv set vrf <vrf> router bgp address-family ipv6-unicast advertise-origin
命令。在所有交换机上(叶、脊和超级脊交换机),启用每个源的下一跳组选项。以下示例为 IPv4 启用每个源的下一跳组选项
cumulus@spine01:~$ nv set vrf default router bgp address-family ipv4-unicast nhg-per-origin cumulus@spine01:~$ nv config apply
对于 IPv6,运行
nv set vrf <vrf> router bgp address-family ipv6-unicast nhg-per-origin
命令。在脊和超级脊交换机上,将 BGP 收敛等待时间设置为 30,将收敛等待建立等待时间设置为 15。
cumulus@leaf01:~$ nv set router bgp convergence-wait time 30 cumulus@leaf01:~$ nv set router bgp convergence-wait establish-wait-time 15 cumulus@leaf01:~$ nv config apply
要禁用 BGP PIC,请在叶交换机上运行 nv unset vrf <vrf> router bgp address-family <address-family> advertise-origin
命令,并在所有交换机上运行 nv unset vrf <vrf> router bgp address-family <address-family> nhg-per-origin
命令。
在叶交换机上,启用 BGP 宣告源选项。以下示例为 IPv4 启用 BGP 宣告源选项
cumulus@leaf01:~$ sudo vtysh ... leaf01# configure terminal leaf01(config)# router bgp 65101 leaf01(config-router)# address-family ipv4 leaf01(config-router-af)# bgp advertise-origin leaf01(config-router-af)# end leaf01# write memory leaf01# exit
在所有交换机上(叶、脊和超级脊交换机),启用每个源的下一跳组选项。以下示例为 IPv4 启用 BGP 每个源的下一跳组
cumulus@spine01:~$ sudo vtysh ... spine01# configure terminal spine01(config)# router bgp 65101 spine01(config-router)# address-family ipv4 spine01(config-router-af)# bgp nhg-per-origin spine01(config-router-af)# end spine01# write memory spine01# exit
在脊和超级脊交换机上,将 BGP 收敛等待时间设置为 30,将收敛等待建立等待时间设置为 15。
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp
leaf01(config-router)# update-delay 30 15
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
bgp update-delay 30 15
router bgp 65101
...
address-family ipv4 unicast
...
bgp advertise-origin
bgp nhg-per-origin
...
要禁用 BGP PIC,请在叶交换机上使用 no bgp advertise-origin
命令,在所有交换机上使用 no bgp nhg-per-origin
命令。例如
cumulus@spine02:~$ sudo vtysh
...
spine01# configure terminal
spine01(config)# router bgp 65101
spine01(config-router)# address-family ipv4
spine01(config-router-af)# no bgp nhg-per-origin
spine01(config-router-af)# end
spine01# write memory
spine01# exit
Cumulus Linux 提供了多个 show 命令来帮助您排查 BGP PIC 故障。请参阅 显示前缀无关收敛信息。
BGP 计时器
BGP 包括多个您可以配置的计时器。
Keepalive 间隔和保持时间
默认情况下,BGP 交换周期性 keepalive 消息,以测量和确保对等方仍然存活且正常运行。如果 BGP 在保持时间内未收到来自对等方的 keepalive 或更新消息,它将声明对等方已关闭,并从本地 BGP 表中撤回由此对等方接收的所有路由。默认情况下,keepalive 间隔为 3 秒,保持时间为 9 秒。当存在大量邻居时,为了降低 CPU 负载,您可以增加这些计时器的值或禁用 keepalive 交换。手动配置新值时,keepalive 间隔可以小于或等于保持时间的三分之一,但不能少于 1 秒。将 keepalive 和保持时间值设置为 0 将禁用 keepalive 交换。
以下示例命令将 keepalive 间隔设置为 10 秒,保持时间设置为 30 秒。
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 timers keepalive 10
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 timers hold 30
cumulus@leaf01:~$ nv config apply
要将计时器设置回默认值,请运行 nv unset vrf <vrf> router bgp neighbor <interface> timers keepalive
和 nv unset vrf <vrf> router bgp neighbor <interface> timers hold
命令。
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp
leaf01(config-router)# neighbor swp51 timers 10 30
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65101
...
neighbor swp51 timers 10 30
...
重连间隔
默认情况下,BGP 进程在故障后(或启动时)每 10 秒尝试连接到对等方。您可以更改此值以满足您的需求。
以下示例命令将重连值设置为 30 秒
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 timers connection-retry 30
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp
leaf01(config-router)# neighbor swp51 timers connect 30
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65101
...
neighbor swp51 timers connect 30
...
通告间隔
在为前缀做出新的最佳路径决策后,BGP 可以在将新结果通告给对等方之前插入延迟。此延迟速率限制了通告给下游对等方的更改量,并通过减慢收敛速度来降低处理要求。默认情况下,eBGP 和 iBGP 会话的此间隔均为 0 秒,这允许快速收敛。有关通告间隔的更多信息,请参阅 此 IETF 草案。
以下示例命令将通告间隔设置为 5 秒
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 timers route-advertisement 5
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp
leaf01(config-router)# neighbor swp51 advertisement-interval 5
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65101
...
neighbor swp51 advertisement-interval 5
...
BGP 输入和输出消息队列限制
您可以为所有对等方配置输入和输出消息队列限制。对于输入和输出队列限制,您可以设置介于 1 和 4294967295 条消息之间的值。默认设置为 10000。
仅当您有足够的内存同时处理大量消息队列时,才增加输入或输出队列。
以下示例将输入队列限制设置为 2048 条消息,将输出队列限制设置为 2048 条消息
cumulus@leaf01:~$ nv set router bgp queue-limit input 2048
cumulus@leaf01:~$ nv set router bgp queue-limit output 2048
cumulus@leaf01:~$ nv config apply
以下示例将输入队列限制设置为 2048 条消息,将输出队列限制设置为 2048 条消息
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# bgp input-queue-limit 2048
leaf01(config)# bgp output-queue-limit 2048
leaf01(config)# end
leaf01# write memory
leaf01# exit
要显示输入和输出消息队列配置,请运行 nv show router bgp queue-limit
命令。
路由反射器
iBGP 规则规定,BGP 不能将从 iBGP 对等方学习的路由发送到另一个 iBGP 对等方。在使用 iBGP 的数据中心脊叶网络中,这会阻止脊交换机将从叶交换机学习的路由发送到任何其他叶交换机。作为一种解决方法,您可以使用路由反射器。当 iBGP 扬声器是路由反射器时,它可以将 iBGP 学习的路由发送到其他 iBGP 对等方。
在以下示例中,spine01 充当路由反射器。叶交换机 leaf01、leaf02 和 leaf03 是路由反射器客户端。BGP 将 spine01 从路由反射器客户端学习的任何路由发送到其他路由反射器客户端。

要将 BGP 节点配置为 BGP 对等方的路由反射器,请设置邻居 route-reflector-client
选项。以下示例将上图所示的 spine01 设置为 leaf01(在 swp1 上)的路由反射器,后者是路由反射器客户端。您不必配置客户端。
cumulus@spine01:~$ nv set vrf default router bgp neighbor swp1 address-family ipv4-unicast route-reflector-client on
cumulus@spine01:~$ nv config apply
cumulus@spine01:~$ sudo vtysh
...
spine01# configure terminal
spine01(config)# router bgp 65199
spine01(config-router)# address-family ipv4
spine01(config-router-af)# neighbor swp1 route-reflector-client
spine01(config-router-af)# end
spine01# write memory
spine01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65199
bgp router-id 10.10.10.101
neighbor swp51 remote-as external
!
address-family ipv4 unicast
network 10.10.10.101/32
neighbor swp51 route-reflector-client
exit-address-family
...
- 当您为 IPv6 配置 BGP 时,您必须在
activate
命令之后运行route-reflector-client
命令。 - 您只能将 BGP 节点配置为 iBGP 对等方的路由反射器。
BGP 联盟
要减少 iBGP 对等连接的数量,请配置联盟以将 AS 划分为更小的 子 AS。
要配置 BGP 联盟
- 提供您要使用的配置 ID。
- 提供您要添加到联盟的对等方的 ASN。
以下示例配置联盟 ID 2,子 AS 为 65101、65102、65103 和 65104。
cumulus@spine01:~$ nv set vrf default router bgp confederation id 2
cumulus@spine01:~$ nv set vrf default router bgp confederation member-as 65101-65104
cumulus@spine01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
spine01# configure terminal
spine01(config)# router bgp 65199
spine01(config-router)# bgp confederation identifier 2
spine01(config-router)# bgp confederation peers 65101
spine01(config-router)# bgp confederation peers 65102
spine01(config-router)# bgp confederation peers 65103
spine01(config-router)# bgp confederation peers 65104
spine01(config-router)# end
spine01# write memory
spine01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
cumulus@spine01:~$ sudo cat /etc/frr/frr.conf
...
router bgp 65199
bgp router-id 10.10.10.101
bgp confederation identifier 2
bgp confederation peers 65101 65102 65103 65104
...
管理距离
当两种不同的协议为同一目的地提供路由信息时,Cumulus Linux 使用管理距离来选择要使用的路由协议。距离越小,协议越可靠。例如,如果交换机从 OSPF 接收到管理距离为 110 的路由,并从 BGP 接收到管理距离为 100 的相同路由,则交换机选择 BGP。
以下示例命令将外部路由的管理距离设置为 150,内部路由的管理距离设置为 110
cumulus@spine01:~$ nv set vrf default router bgp address-family ipv4-unicast admin-distance external 150
cumulus@spine01:~$ nv set vrf default router bgp address-family ipv4-unicast admin-distance internal 110
cumulus@spine01:~$ nv config apply
cumulus@spine01:~$ sudo vtysh
...
spine01# configure terminal
spine01(config)# router bgp 65101
spine01(config-router)# distance bgp 150 110
spine01(config-router)# end
spine01# write memory
spine01# exit
BGP 邻居关闭
您可以关闭与邻居的所有活动 BGP 会话,并删除所有相关的路由信息,而无需删除其关联的配置。关闭后,邻居将进入管理空闲状态。
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 shutdown on
cumulus@leaf01:~$ nv config apply
要恢复与邻居的 BGP 会话,请运行 nv set vrf default router bgp neighbor swp51 shutdown off
命令。
cumulus@spine01:~$ sudo vtysh
...
spine01# configure terminal
spine01(config)# router bgp 65101
spine01(config-router)# neighbor swp51 shutdown
spine01(config-router)# end
spine01# write memory
spine01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65199
...
neighbor swp51 shutdown
...
要恢复与邻居的 BGP 会话,请运行 no neighbor swp51 shutdown
命令。
优雅 BGP 关闭
为了减少计划的交换机或链路维护期间的数据包丢失,您可以全局、在对等组或特定对等方上配置优雅 BGP 关闭。
如果在任何级别(全局、对等组或特定对等方)启用优雅关闭,则优雅关闭对对等方有效。如果在所有级别(全局、对等组和特定对等方)禁用优雅关闭,则优雅关闭对对等方无效。
全局优雅 BGP 关闭
当您在交换机上全局启用优雅关闭时,Cumulus Linux 会将 graceful-shutdown
社区添加到来自所有 eBGP 对等方的所有入站和出站路由,并将路由的 local-pref
设置为 0
(请参阅 RFC8326)。
要在交换机上全局启用优雅关闭
cumulus@leaf01:~$ nv set router bgp graceful-shutdown on
cumulus@leaf01:~$ nv config apply
要在交换机上全局禁用优雅关闭
cumulus@leaf01:~$ nv set router bgp graceful-shutdown off
cumulus@leaf01:~$ nv config apply
要全局启用优雅关闭
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# bgp graceful-shutdown
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
要在交换机上全局禁用优雅关闭
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# no bgp graceful-shutdown
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
要显示配置,请运行 vtysh show ip bgp <route>
命令。例如
cumulus@leaf01:~$ sudo vtysh
leaf01# show ip bgp 10.10.10.0/24
BGP routing table entry for 10.10.10.0/24
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Advertised to non peer-group peers:
bottom0(10.10.10.2)
30 20
10.10.10.2 (metric 10) from top1(10.10.10.2) (10.10.10.2)
Origin IGP, localpref 100, valid, internal, bestpath-from-AS 30, best
Community: 99:1
AddPath ID: RX 0, TX 52
Last update: Mon Sep 18 17:01:18 2017
20
10.10.10.3 from bottom0(10.10.10.32) (10.10.10.10)
Origin IGP, metric 0, localpref 0, valid, external, bestpath-from-AS 20
Community: 99:1 graceful-shutdown
AddPath ID: RX 0, TX 2
Last update: Mon Sep 18 17:01:18 2017
作为可选配置,您可以创建路由映射来预先添加 AS,以便使用更长的 AS 路径降低首选项传播到网络的其他部分。
对等方上的优雅 BGP 关闭
当您在对等方上启用 BGP 优雅关闭时,Cumulus Linux 会将 graceful-shutdown
社区附加到相关路由。接收到 graceful-shutdown
社区的邻居会将这些路由标记为优先级较低(如果存在备用路由)。如果没有其他路由可用,邻居将继续使用带有 graceful-shutdown
社区的路由。如果您在网络的多个部分或没有其他路由的地方启用优雅关闭(维护),则流量不会在附加了 graceful-shutdown
社区的路由上停止。
要在对等方上启用优雅关闭,请运行 nv set vrf <vrf> router bgp neighbor <neighbor> graceful-shutdown on
命令
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 graceful-shutdown on
cumulus@leaf01:~$ nv config apply
要在对等方上禁用优雅关闭,请运行 nv unset vrf <vrf> router bgp neighbor <neighbor> graceful-shutdown
命令
cumulus@leaf01:~$ nv unset vrf default router bgp neighbor swp51 graceful-shutdown
cumulus@leaf01:~$ nv config apply
要在对等方上启用优雅关闭
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor swp51 graceful-shutdown
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
要在对等方上禁用优雅关闭
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor swp51 no graceful-shutdown
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
要显示优雅关闭是否在对等方上为 on
,请运行 nv show vrf <vrf> router bgp neighbor <neighbor>
命令
cumulus@leaf01:~$ nv show vrf default router bgp neighbor swp51
operational applied
---------------------------------- ------------------------------ ----------
password *
enforce-first-as off
passive-mode off
nexthop-connected-check on
description none
bfd
enable off
...
graceful-shutdown on
...
对等组上的优雅 BGP 关闭
当您在对等组上启用 BGP 优雅关闭时,Cumulus Linux 会将 graceful-shutdown
社区附加到相关路由。接收到 graceful-shutdown
社区的邻居会将这些路由标记为优先级较低(如果存在备用路由)。如果没有其他路由可用,邻居将继续使用带有 graceful-shutdown
社区的路由。如果您在网络的多个部分或没有其他路由的地方启用优雅关闭(维护),则流量不会在附加了 graceful-shutdown
社区的路由上停止。
要在对等组上启用优雅关闭,请运行 nv set vrf <vrf> router bgp peer-group <peer-group-id> graceful-shutdown on
命令
cumulus@leaf01:~$ nv set vrf default router bgp peer-group underlay graceful-shutdown on
cumulus@leaf01:~$ nv config apply
要在对等组上禁用优雅关闭,请运行 nv unset vrf <vrf> router bgp peer-group <peer-group-id> graceful-shutdown
命令
cumulus@leaf01:~$ nv unset vrf default router bgp peer-group underlay graceful-shutdown
cumulus@leaf01:~$ nv config apply
要在对等组上启用优雅关闭
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor underlay graceful-shutdown
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
要在对等组上禁用优雅关闭
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor underlay no graceful-shutdown
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
要显示优雅关闭是否在对等组上为 on
,请运行 nv show vrf <vrf> router bgp peer-group <peer-group-id>
命令
cumulus@leaf01:~$ nv show vrf default router bgp peer-group underlay
operational applied
---------------------------------- ------------------------------ ----------
password *
enforce-first-as off
passive-mode off
nexthop-connected-check on
description none
bfd
enable off
...
graceful-shutdown on
...
优雅 BGP 重启
当 BGP 在交换机上重启时,所有 BGP 对等方都会检测到会话关闭并重新启动。此会话转换会导致 BGP 对等方上的路由抖动,从而导致 BGP 重新计算路由、生成路由更新以及向转发表添加不必要的抖动。路由抖动可能会创建瞬态转发黑洞和环路,并消耗受抖动影响的交换机上的资源,这可能会影响整体网络性能。
为了最大限度地减少 BGP 重启时发生的负面影响,Cumulus Linux 默认启用优雅 BGP 重启,这使 BGP 扬声器可以向其对等方发出信号,表明它可以保留其转发状态并在重启期间继续数据转发。BGP 优雅重启还使 BGP 扬声器即使在对等方关闭后,也能继续使用对等方通告的路由。
当 BGP 建立会话时,BGP 对等方使用 BGP OPEN 消息来协商优雅重启。如果 BGP 对等方也支持优雅重启,则它将为该邻居会话激活。如果 BGP 会话停止,BGP 对等方(重启助手)会将与设备关联的所有路由标记为陈旧,但会在一定时间内继续将数据包转发到这些路由。重启设备也会在优雅重启期间继续转发数据包。设备恢复并再次与其对等方(重启助手)建立 BGP 会话后,它会等待学习这些对等方通告的所有路由,然后再选择累积路径;之后,它会更新其转发表并将相应的路由重新通告给其对等方。这些过程确保如果在 BGP 扬声器重启时有任何路由更改,网络都会收敛。
- 对于热启动以重启交换机,而不会中断现有路由条目的流量,您必须在所有 BGP VRF 中启用 BGP 优雅重启。
- BGP 优雅重启仅支持 eBGP 直接和多跳对等连接。VRF 泄漏无法优雅处理,并且在优雅重启进行期间,通过这些路由到达目的地的流量可能会丢失。
重启模式
Cumulus Linux 支持 IPv4、IPv6 和 EVPN 的优雅 BGP 重启完全模式和仅助手模式。默认设置为仅助手模式。
- 在完全模式下,交换机既充当助手角色,又充当重启器角色。
- 在仅助手模式下,交换机仅充当助手角色,其中从 BGP 对等方发起和通告的路由不会被删除。
您可以全局配置优雅 BGP 重启,其中所有 BGP 对等方都继承优雅重启功能,或者为 BGP 对等方或对等组配置优雅 BGP 重启(适用于行为异常的对等方或与第三方设备配合使用时)。
- BGP 通过计划的交换机重启事件(ISSU 启动)进行优雅重启(作为重启路由器)。任何其他时候 BGP 重启,例如当 BGP 守护程序因软件异常而重启,或者您重启 FRR 服务时,BGP 都会经历常规重启,其中与对等方的 BGP 会话终止,并且 Cumulus Linux 从转发平面中删除学习到的路由。
- 更改优雅重启模式会导致 BGP 会话抖动。
默认情况下,交换机在仅助手模式下启用了优雅重启。要在交换机上全局将优雅 BGP 重启设置为完全模式
cumulus@leaf01:~$ nv set router bgp graceful-restart mode full
cumulus@leaf01:~$ nv config apply
要在连接到 swp51 的 BGP 对等方上将优雅 BGP 重启设置为完全模式
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 graceful-restart mode full
cumulus@leaf01:~$ nv config apply
要将优雅 BGP 重启设置回默认设置(仅助手模式),请运行 nv unset router bgp graceful-restart
命令或 nv set router bgp graceful-restart mode helper-only
命令。
默认情况下,交换机在仅助手模式下启用了优雅重启。要在交换机上全局将优雅 BGP 重启设置为完全模式
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# bgp graceful-restart
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
要在连接到 swp51 的 BGP 对等方上将优雅 BGP 重启设置为完全模式
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor swp51 graceful-restart
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
要将优雅 BGP 重启设置回默认设置(仅助手模式),请运行 no bgp graceful-restart
命令或 no neighbor <interface> graceful-restart
命令
禁用优雅重启
如果您禁用优雅 BGP 重启,则在 BGP 配置中无法实现交换机重启或交换机软件升级,且数据包丢失最少。有关更多信息,请参阅 ISSU。
要在交换机上全局禁用优雅 BGP 重启
cumulus@leaf01:~$ nv set router bgp graceful-restart mode off
cumulus@leaf01:~$ nv config apply
要在 BGP 对等方上禁用优雅 BGP 重启
cumulus@leaf01:~$ nv unset vrf default router bgp neighbor swp51 graceful-restart
cumulus@leaf01:~$ nv config apply
要在交换机上全局禁用优雅 BGP 重启
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# bgp graceful-restart-disable
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
要在 BGP 对等方上禁用优雅 BGP 重启
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# neighbor swp51 graceful-restart-disable
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
重启计时器
您可以配置以下优雅 BGP 重启计时器。
计时器 | 描述 |
---|---|
restart-time | 等待支持优雅重启的对等方重新建立 BGP 对等连接的秒数。您可以设置介于 1 和 4095 之间的值。默认值为 120 秒。 |
pathselect-defer-time | 重启对等方在等待来自对等方的 EOR 标记时延迟路径选择的秒数。您可以设置介于 0 和 3600 之间的值。默认值为 360 秒。 |
stalepath-time | 为重启对等方保留陈旧路由的秒数。您可以设置介于 1 和 4095 之间的值。默认值为 360 秒。 |
为了避免在具有多跳 BGP 会话的 EVPN 多宿主配置中进行热启动期间发生流量丢失,请在所有多宿主配置的交换机上将 restart-time
计时器增加到 180 秒以上。
以下示例命令将 restart-time
设置为 400 秒,将 pathselect-defer-time
设置为 300 秒,将 stalepath-time
设置为 400 秒
cumulus@leaf01:~$ nv set router bgp graceful-restart restart-time 400
cumulus@leaf01:~$ nv set router bgp graceful-restart path-selection-deferral-time 300
cumulus@leaf01:~$ nv set router bgp graceful-restart stale-routes-time 400
cumulus@leaf01:~$ nv config apply
计时器 | 描述 |
---|---|
notification | 为 BGP NOTIFICATION 消息启用优雅 BGP 重启支持。 |
preserve-fw-state | 设置 F 位指示以在优雅 BPG 重启期间保留 FIB。 |
restart-time | 等待支持优雅重启的对等方重新建立 BGP 对等连接的秒数。您可以设置介于 1 和 4095 之间的值。默认值为 120 秒。 |
rib-stale-time | RIB 中陈旧路由删除时间(以秒为单位)。您可以设置介于 1 和 3600 之间的值。 |
select-defer-time | 重启对等方在等待来自对等方的 EOR 标记时延迟路径选择的秒数。您可以设置介于 0 和 3600 之间的值。默认值为 360 秒。 |
stalepath-time | 为重启对等方保留陈旧路由的秒数。您可以设置介于 1 和 4095 之间的值。默认值为 360 秒。 |
以下示例命令将 restart-time
设置为 400 秒,将 pathselect-defer-time
设置为 300 秒,将 stalepath-time
设置为 400 秒
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# bgp graceful-restart restart-time 400
leaf01(config-router)# bgp graceful-restart select-defer-time 300
leaf01(config-router)# bgp graceful-restart stalepath-time 400
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65199
bgp router-id 10.10.10.101
neighbor swp51 remote-as external
bgp graceful-restart restart-time 400
bgp graceful-restart select-defer-time 300
bgp graceful-restart stalepath-time 400
...
显示优雅重启信息
要显示全局优雅 BGP 重启配置设置,请运行 NVUE nv show router bgp graceful-restart
命令
cumulus@leaf01:mgmt:~$ nv show router bgp graceful-restart
applied pending
---------------------------- ----------- -----------
mode helper-only helper-only
restart-time 120 120
path-selection-deferral-time 360 360
stale-routes-time 360 360
要显示特定 BGP 对等方上的优雅 BGP 重启信息,请运行 vtysh show ip bgp neighbor <neighbor> graceful-restart
命令。
cumulus@leaf01:mgmt:~$ sudo vtysh
...
leaf01# show ip bgp neighbor swp51 graceful-restart
Codes: GR - Graceful Restart, * - Inheriting Global GR Config,
Restart - GR Mode-Restarting, Helper - GR Mode-Helper,
Disable - GR Mode-Disable.
BGP neighbor on swp51: fe80::4638:39ff:fe00:2, remote AS 65199, local AS 65101, external link
BGP state = Established, up for 00:15:54
Neighbor GR capabilities:
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: False
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: Yes
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
启用只读模式
有时,当 Cumulus Linux 建立 BGP 对等连接并接收更新时,它会在接收和处理来自所有对等方的信息之前,将前缀安装到 RIB 中并将其通告给 BGP 对等方。此外,根据更新的时间,Cumulus Linux 有时会安装前缀,然后撤回并用新的路由信息替换它们。只读模式最大限度地减少了本地 RIB 和 BGP 对等方中的这种 BGP 路由抖动。
在重启 BGP 进程时,启用只读模式以减少 CPU 和网络使用率。由于对于同一前缀,中间最佳路径可能随着对等方建立并在不同时间开始接收更新而出现,因此只读模式在 BGP 从大量对等方学习前缀且网络具有大量前缀的拓扑中非常有用。
在只读模式下,BGP 不运行最佳路径或生成任何对其对等方的更新。
以下示例命令启用只读模式
cumulus@leaf01:~$ nv set router bgp convergence-wait time 300
cumulus@leaf01:~$ nv set router bgp convergence-wait establish-wait-time 200
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp
leaf01(config-router)# update-delay 300 90
leaf01(config-router)# end
leaf01# write memory
leaf01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如
...
router bgp 65199
bgp router-id 10.10.10.101
neighbor swp51 remote-as external
bgp update-delay 300 200
...
要显示配置的计时器和有关收敛事件发生时转换的信息,请运行 vtysh show ip bgp summary
命令。
cumulus@leaf01:mgmt:~$ sudo vtysh
...
leaf01# show ip bgp summary
ipv4 Unicast Summary
BGP router identifier 10.10.10.1, local AS number 65101 vrf-id 0
Read-only mode update-delay limit: 300 seconds
Establish wait: 200 seconds
BGP table version 0
RIB entries 3, using 576 bytes of memory
Peers 1, using 21 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt
spine01(swp51) 4 65199 30798 30802 0 0 0 1d01h09m 0 0
Total number of neighbors 1
...
vtysh show ip bgp summary json
命令显示上次收敛事件。
BGP 社区列表
您可以使用社区列表来定义 BGP 社区,以标记一个或多个路由。然后,您可以将社区用于出口或入口的路由策略。
BGP 社区列表可以是标准、扩展或大型。标准 BGP 社区列表是一对值(例如 100:100),您可以将其标记在特定前缀上并通告给其他邻居,或者您可以将其应用于路由入口。标准 BGP 社区列表可以是四个 BGP 默认社区之一
- internet:与所有路由匹配的 BGP 社区
- local-AS:将路由限制为您的联盟子 AS 的 BGP 社区
- no-advertise:不通告给任何人的 BGP 社区
- no-export:不通告给 eBGP 对等方的 BGP 社区
扩展 BGP 社区列表采用社区的正则表达式,并匹配列出的社区。
大型社区列表容纳更多识别信息,包括 4 字节 AS 号。默认情况下,BGP 启用大型社区。要禁用大型社区,请运行 nv set vrf <vrf> router bgp neighbor <neighbor> address-family <address-family> community-advertise large off
命令或 nv set vrf <vrf> router bgp peer-group <peer-group> address-family <address-family> community-advertise large off
命令。
当邻居收到前缀时,它会检查社区值并采取相应的操作,例如允许或拒绝路由策略中的社区成员。
如果您在路由策略的 BGP 社区列表、扩展社区列表或大型社区列表正则表达式中包含逗号,您将看到错误消息,并且 FRR 重新加载失败。确保正则表达式不包含逗号。
以下示例配置标准社区列表过滤器
cumulus@leaf01:~$ nv set router policy community-list COMMUNITY1 rule 10 action permit
cumulus@leaf01:~$ nv set router policy community-list COMMUNITY1 rule 10 community 100:100
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# bgp community-list standard COMMUNITY1 permit 100:100
leaf01(config)# exit
leaf01# write memory
leaf01# exit
要将社区列表应用于路由映射以定义路由策略
cumulus@leaf01:~$ nv set router policy route-map ROUTEMAP1 rule 10 match community-list COMMUNITY1
cumulus@leaf01:~$ nv set router policy route-map ROUTEMAP1 rule 10 action permit
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# route-map ROUTEMAP1
leaf01(config-route-map)# match community COMMUNITY1
leaf01(config-route-map)# end
leaf01# write memory
leaf01# exit
以下示例配置 BGP 扩展社区 RT 过滤器,并将扩展社区列表应用于路由映射。
cumulus@leaf01:~$ nv set router policy ext-community-list EXTCOMM1 rule 10 ext-community rt 11:11,22:22
cumulus@leaf01:~$ nv set router policy ext-community-list EXTCOMM1 rule 10 action permit
cumulus@leaf01:~$ nv set router policy route-map ROUTEMAP1 rule 10 match ext-community-list EXTCOMM1
cumulus@leaf01:~$ nv set router policy route-map ROUTEMAP1 rule 10 action permit
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# bgp extcommunity standard EXTCOMM1 permit rt 11:11 rt 22:22
leaf01(config)# route-map ROUTEMAP1 permit 10
leaf01(config-route-map)# match extcommunity EXTCOMM1
leaf01(config-route-map)# end
leaf01# write memory
leaf01# exit
以下示例配置具有正则表达式匹配的 BGP 扩展社区 RT 过滤器,并将扩展社区列表应用于路由映射。
cumulus@leaf01:~$ nv set router policy ext-community-list EXTCOMM2 rule 10 ext-community rt "\.*_65000:2002_.*","\.*_89000:2002_.*"
cumulus@leaf01:~$ nv set router policy ext-community-list EXTCOMM2 rule 10 action permit
cumulus@leaf01:~$ nv set router policy ROUTEMAP3 rule 10 match ext-community-list EXTCOMM2
cumulus@leaf01:~$ nv set router policy route-map ROUTEMAP3 rule 10 action permit
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# bgp extcommunity expanded EXTCOMM2 permit rt "\.*_65000:2002_.*","\.*_89000:2002_.*"
leaf01(config)# route-map ROUTEMAP3 permit 10
leaf01(config-route-map)# match extcommunity EXTCOMM2
leaf01(config-route-map)# end
leaf01# write memory
leaf01# exit
以下示例配置 BGP 扩展社区 SOO 过滤器,并将扩展社区列表应用于路由映射。
cumulus@leaf01:~$ nv set router policy ext-community-list EXTCOMM1 rule 10 ext-community soo 66:66,77:77
cumulus@leaf01:~$ nv set router policy ext-community-list EXTCOMM1 rule 10 action permit
cumulus@leaf01:~$ nv set router policy route-map ROUTEMAP1 rule 10 match ext-community-list EXTCOMM1
cumulus@leaf01:~$ nv set router policy route-map ROUTEMAP1 rule 10 action permit
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# bgp extcommunity standard EXTCOMM2 permit soo 66:66 soo 77:77
leaf01(config)# route-map ROUTEMAP1 permit 10
leaf01(config-route-map)# match extcommunity EXTCOMM2
leaf01(config)# end
leaf01# write memory
leaf01# exit
以下示例配置具有正则表达式匹配的 BGP 扩展社区 SOO 过滤器,并将扩展社区列表应用于路由映射。
cumulus@leaf01:~$ nv set router policy ext-community-list EXTCOMM2 rule 10 ext-community soo "\.*_65000:2002_.*","\.*_89000:2002_.*"
cumulus@leaf01:~$ nv set router policy ext-community-list EXTCOMM2 rule 10 action permit
cumulus@leaf01:~$ nv set router policy route-map ROUTEMAP20 rule 10 match ext-community-list EXTCOMM2
cumulus@leaf01:~$ nv set router policy route-map ROUTEMAP20 rule 10 action permit
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# bgp extcommunity expanded EXTCOMM2 permit soo "\.*_65000:2002_.*","\.*_89000:2002_.*"
leaf01(config)# route-map ROUTEMAP20 permit 10
leaf01(config-route-map)# match extcommunity EXTCOMM2
leaf01(config)# exit
leaf01# write memory
leaf01# exit
要使用特殊字符(例如句点 (.))在扩展 BGP 社区列表的正则表达式中,您必须使用反斜杠 (\
) 转义字符。例如,nv set router policy community-list COMMUNITY1 rule 10 community "\.*_65000:2002_.*"
。
以下示例配置 BGP 大型社区列表,并将大型社区列表应用于路由映射。
cumulus@leaf01:~$ nv set router policy large-community-list 11 rule 10 action permit
cumulus@leaf01:~$ nv set router policy large-community-list 11 rule 10 large-community 4200857911:011:011
cumulus@leaf01:~$ nv set router policy route-map MAP1 rule 10 match large-community-list mylist
cumulus@leaf01:~$ nv set router policy route-map MAP1 rule 10 action permit
cumulus@leaf01:~$ nv config apply
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# bgp large-community-list 11 seq 10 permit 4200857911:011:011
leaf01(config)# route-map MAP1 permit 10
leaf01(config-route-map)# match large-community 11
leaf01(config-route-map)# end
leaf01# write memory
leaf01# exit
cumulus@leaf01:~$
Cumulus Linux 将 BGP 路由上的完整社区列表视为要评估的单个字符串。如果您尝试匹配 $
(以结尾),Cumulus Linux 会匹配社区列表中的最后一个社区值,而不是列表中的单个社区值。
例如,如果您使用正则表达式 ".*:(20)$"
,Cumulus Linux 会匹配所有社区列表以 20 结尾的 BGP 路由。
- 社区为 45000:10 55000:40 65000:15000 123:20 的路由匹配。
- 社区为 45000:10 55000:20 65000:15000 的路由不匹配。