基本 BGP 配置
本节介绍如何使用 BGP 编号或 BGP 无编号 配置 BGP。使用 BGP无编号,您可以在 Cumulus Linux 交换机之间设置 BGP 对等互连,并交换 IPv4 前缀,而无需在每个交换机上配置 IPv4 地址。
BGP无编号简化了配置。NVIDIA 建议您对数据中心部署使用 BGP 无编号。
首次启用 BGP 时,FRR 服务会重新启动,这可能会影响流量。任何时候您启用或禁用 BGP,或更改 ASN,FRR 服务也会重新启动。
BGP 编号
要在 BGP 节点上配置 BGP 编号,您需要:
- 分配一个 ASN 以标识此 BGP 节点。在两层叶脊配置中,您可以使用 自动 BGP,其中 Cumulus Linux 自动分配 ASN。
- 如有必要,请指定路由器 ID。NVUE 自动将交换机的环回地址分配为路由器 ID。FRR 自动将路由器 ID 分配为环回地址或接口的最高 IPv4 地址。如果您没有配置环回地址或想要使用特定的路由器 ID,请全局或按 VRF 设置路由器 ID。
- 通过提供邻居的 IP 地址和 ASN,指定路由信息的分配位置。
- 对于 BGP 编号,这是两个对等方之间接口的 IP 地址;该接口必须是第 3 层接入端口。
- ASN 可以是数字,对于同一 AS 中的邻居,可以是
internal
,对于不同 AS 中的邻居,可以是external
。
- 指定要从此 BGP 节点始发的哪些前缀。
通过分配 ASN 来标识 BGP 节点。
要手动分配 ASN:
cumulus@leaf01:~$ nv set router bgp autonomous-system 65101
要在叶节点上使用自动 BGP 自动分配 ASN:
cumulus@leaf01:~$ nv set router bgp autonomous-system leaf
自动 BGP
leaf
关键字仅用于配置 ASN。配置文件和nv show
命令显示 AS 号。
BGP 自动将交换机的环回地址分配为路由器 ID。如果您没有配置环回地址,或者不想使用环回地址作为路由器 ID,您必须使用
nv set router bgp router-id
命令全局分配路由器 ID,或使用nv set vrf <vrf> router bgp router-id
命令在 VRF 中分配路由器 ID。如果您未在 VRF 中设置路由器 ID,则 BGP 使用全局路由器 ID。cumulus@leaf01:~$ nv set router bgp router-id 10.10.10.1
指定要向其分发路由信息的 BGP 邻居。
cumulus@leaf01:~$ nv set vrf default router bgp neighbor 10.0.1.0 remote-as external
为了让 BGP 播发 IPv6 前缀,您需要运行额外的命令来激活 IPv6 地址族下的 BGP 邻居。Cumulus Linux 默认启用 IPv4 地址族;您无需为 IPv4 路由交换运行
activate
命令。cumulus@leaf01:~$ nv set vrf default router bgp neighbor 2001:db8:0002::0a00:0002 remote-as external cumulus@leaf01:~$ nv set vrf default router bgp neighbor 2001:db8:0002::0a00:0002 address-family ipv6-unicast enable on
为了让 BGP 使用 IPv6 下一跳播发IPv4 前缀,请参阅使用 IPv6 下一跳播发 IPv4 前缀。
指定要始发的哪些前缀
cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv4-unicast network 10.10.10.1/32 cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv4-unicast network 10.1.10.0/24 cumulus@leaf01:~$ nv config apply
IPv6 前缀示例
cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv6-unicast network 2001:db8::1/128 cumulus@leaf01:~$ nv config apply
NVUE 命令在 /etc/nvue.d/startup.yaml
文件中创建以下配置代码段:
cumulus@leaf01:~$ sudo cat /etc/nvue.d/startup.yaml
...
- set:
router:
bgp:
autonomous-system: 65101
enable: on
router-id: 10.10.10.1
vrf:
default:
router:
bgp:
address-family:
ipv4-unicast:
enable: on
network:
10.1.10.0/24: {}
10.10.10.1/32: {}
enable: on
neighbor:
10.0.1.0:
remote-as: external
type: numbered
通过分配 ASN 来标识 BGP 节点。
要手动分配 ASN:
cumulus@spine01:~$ nv set router bgp autonomous-system 65199
要在脊节点上使用自动 BGP 自动分配 ASN:
cumulus@spine01:~$ nv set router bgp autonomous-system spine
自动 BGP
spine
关键字仅用于配置 ASN。配置文件和nv show
命令显示 AS 号。
BGP 自动将交换机的环回地址分配为路由器 ID。如果您没有配置环回地址,或者不想使用环回地址作为路由器 ID,您必须使用
nv set router bgp router-id
命令全局分配路由器 ID,或使用nv set vrf <vrf> router bgp router-id
命令在 VRF 中分配路由器 ID。cumulus@spine01:~$ nv set router bgp router-id 10.10.10.101
指定要向其分发路由信息的 BGP 邻居。
cumulus@spine01:~$ nv set vrf default router bgp neighbor 10.0.1.0 remote-as external
为了让 BGP 播发 IPv6 前缀,您需要运行额外的命令来激活 IPv6 地址族下的 BGP 邻居。Cumulus Linux 默认启用 IPv4 地址族;您无需为 IPv4 路由交换运行
activate
命令。cumulus@spine01:~$ nv set vrf default router bgp neighbor 2001:db8:0002::0a00:1 remote-as external cumulus@spine01:~$ nv set vrf default router bgp neighbor address-family ipv6-unicast 2001:db8:0002::0a00:1 enable on
为了让 BGP 使用 IPv6 下一跳播发IPv4 前缀,请参阅使用 IPv6 下一跳播发 IPv4 前缀。
指定要始发的哪些前缀
cumulus@spine01:~$ nv set vrf default router bgp address-family ipv4-unicast network 10.10.10.101/32 cumulus@spine01:~$ nv config apply
IPv6 前缀示例
cumulus@spine01:~$ nv set vrf default router bgp address-family ipv6-unicast network 2001:db8::101/128 cumulus@spine01:~$ nv config apply
NVUE 命令在 /etc/nvue.d/startup.yaml
文件中创建以下配置代码段:
cumulus@spine01:~$ sudo cat /etc/nvue.d/startup.yaml
...
- set:
router:
bgp:
autonomous-system: 65199
enable: on
router-id: 10.10.10.101
vrf:
default:
router:
bgp:
address-family:
ipv4-unicast:
enable: on
network:
10.10.10.101/32: {}
enable: on
neighbor:
10.0.1.0:
remote-as: external
type: numbered
按照 FRRouting 中的描述启用
bgpd
守护程序。通过分配 ASN 以及必要的路由器 ID 来标识 BGP 节点。
BGP 自动使用环回地址或接口的最高 IPv4 地址分配路由器 ID。如果您想为路由器 ID 分配特定的 IPv4 地址,请全局或按 VRF 添加路由器 ID。
cumulus@leaf01:~$ sudo vtysh ... leaf01# configure terminal leaf01(config)# router bgp 65101 leaf01(config-router)# bgp router-id 10.10.10.1
指定路由信息的分配位置
leaf01(config-router)# neighbor 10.0.1.0 remote-as external
为了让 BGP 播发 IPv6 前缀,您需要运行额外的命令来激活 IPv6 地址族下的 BGP 邻居。Cumulus Linux 默认启用 IPv4 地址族;您无需为 IPv4 路由交换运行
activate
命令。leaf01(config-router)# neighbor 2001:db8:0002::0a00:1 remote-as external leaf01(config-router)# address-family ipv6 unicast leaf01(config-router-af)# neighbor 2001:db8:0002::0a00:1 activate
为了让 BGP 使用 IPv6 下一跳播发IPv4 前缀,请参阅使用 IPv6 下一跳播发 IPv4 前缀。
指定要始发的哪些前缀
leaf01(config-router)# address-family ipv4 leaf01(config-router-af)# network 10.10.10.1/32 leaf01(config-router-af)# network 10.1.10.0/24 leaf01(config-router-af)# end leaf01# write memory leaf01# exit cumulus@leaf01:~$
IPv6 前缀示例
leaf01(config-router)# address-family ipv6 leaf01(config-router-af)# network 2001:db8::1/128 leaf01(config-router-af)# end leaf01# write memory leaf01# exit
按照 FRRouting 中的描述启用
bgpd
守护程序。通过分配 ASN 以及必要的路由器 ID 来标识 BGP 节点。
BGP 自动使用环回地址或接口的最高 IPv4 地址分配路由器 ID。如果您想为路由器 ID 分配特定的 IPv4 地址,请全局或按 VRF 添加路由器 ID。
cumulus@spine01:~$ sudo vtysh ... spine01# configure terminal spine01(config)# router bgp 65199 spine01(config-router)# bgp router-id 10.10.10.101
指定路由信息的分配位置
spine01(config-router)# neighbor 10.0.1.1 remote-as external
为了让 BGP 播发 IPv6 前缀,您需要运行额外的命令来激活 IPv6 地址族下的 BGP 邻居。Cumulus Linux 默认启用 IPv4 地址族;您无需为 IPv4 路由交换运行
activate
命令。spine01(config-router)# neighbor 2001:db8:0002::0a00:0002 remote-as external spine01(config-router)# address-family ipv6 unicast spine01(config-router-af)# neighbor 2001:db8:0002::0a00:0002 activate
为了让 BGP 使用 IPv6 下一跳播发IPv4 前缀,请参阅使用 IPv6 下一跳播发 IPv4 前缀。
指定要始发的哪些前缀
spine01(config-router)# address-family ipv4 spine01(config-router-af)# network 10.10.10.101/32 spine01(config-router-af)# end spine01# write memory spine01# exit
IPv6 前缀
spine01(config-router)# address-family ipv4 spine01(config-router-af)# network 2001:db8::101/128 spine01(config-router-af)# end spine01# write memory spine01# exit
当使用自动 BGP 时,配置中没有对 leaf
或 spine
的引用。自动 BGP 确定系统的 ASN 并使用标准 vtysh 命令对其进行配置。
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如:
cumulus@spine01:~$ sudo cat /etc/frr/frr.conf
...
router bgp 65199
bgp router-id 10.10.10.101
neighbor 10.0.1.1 remote-as external
!
address-family ipv4 unicast
network 10.10.10.101/32
exit-address-family
...
BGP 无编号
以下示例命令显示了两个交换机 leaf01 和 spine01 的基本 BGP 无编号 配置,它们是 eBGP 对等方。
BGP 无编号配置与上面显示的 BGP 编号配置之间的唯一区别在于,BGP 邻居是接口(而不是 IP 地址)。您无需在每侧的两个对等方之间的接口上配置 IP 地址。
cumulus@leaf01:~$ nv set router bgp autonomous-system 65101
cumulus@leaf01:~$ nv set router bgp router-id 10.10.10.1
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 remote-as external
cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv4-unicast network 10.10.10.1/32
cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv4-unicast network 10.1.10.0/24
cumulus@leaf01:~$ nv config apply
为了让 BGP 播发 IPv6 前缀,您需要运行额外的命令来激活 IPv6 地址族下的 BGP 邻居。Cumulus Linux 默认启用 IPv4 地址族;您无需为 IPv4 路由交换运行 activate
命令。
cumulus@leaf01:~$ nv set router bgp autonomous-system 65101
cumulus@leaf01:~$ nv set router bgp router-id 10.10.10.1
cumulus@leaf01:~$ nv set vrf default router bgp neighbor swp51 remote-as external
cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv6-unicast enable on
cumulus@leaf01:~$ nv set vrf default router bgp address-family ipv6-unicast network 2001:db8::1/128
cumulus@leaf01:~$ nv config apply
NVUE 命令在 /etc/nvue.d/startup.yaml
文件中创建以下配置代码段:
cumulus@leaf01:~$ sudo cat /etc/nvue.d/startup.yaml
...
- set:
router:
bgp:
autonomous-system: 65101
enable: on
router-id: 10.10.10.1
vrf:
default:
router:
bgp:
address-family:
ipv4-unicast:
enable: on
network:
10.1.10.0/24: {}
10.10.10.1/32: {}
enable: on
neighbor:
swp51:
remote-as: external
type: unnumbered
cumulus@spine01:~$ nv set router bgp autonomous-system 65199
cumulus@spine01:~$ nv set router bgp router-id 10.10.10.101
cumulus@spine01:~$ nv set vrf default router bgp neighbor swp1 remote-as external
cumulus@spine01:~$ nv set vrf default router bgp address-family ipv4-unicast network 10.10.10.101/32
cumulus@spine01:~$ nv config apply
为了让 BGP 播发 IPv6 前缀,您需要运行额外的命令来激活 IPv6 地址族下的 BGP 邻居。Cumulus Linux 默认启用 IPv4 地址族;您无需为 IPv4 路由交换运行 activate
命令。
cumulus@spine01:~$ nv set router bgp autonomous-system 65199
cumulus@spine01:~$ nv set router bgp router-id 10.10.10.101
cumulus@spine01:~$ nv set vrf default router bgp neighbor swp1 remote-as external
cumulus@spine01:~$ nv set vrf default router bgp address-family ipv6-unicast enable on
cumulus@spine01:~$ nv set vrf default router bgp address-family ipv6-unicast network 2001:db8::101/128
cumulus@spine01:~$ nv config apply
NVUE 命令在 /etc/nvue.d/startup.yaml
文件中创建以下配置代码段:
cumulus@spine01:~$ sudo cat /etc/nvue.d/startup.yaml
...
- set:
router:
bgp:
autonomous-system: 65199
enable: on
router-id: 10.10.10.101
vrf:
default:
router:
bgp:
address-family:
ipv4-unicast:
enable: on
network:
10.10.10.101/32: {}
enable: on
neighbor:
swp1:
remote-as: external
type: unnumbered
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# bgp router-id 10.10.10.1
leaf01(config-router)# neighbor swp51 interface remote-as external
leaf01(config-router)# address-family ipv4
leaf01(config-router-af)# network 10.10.10.1/32
leaf01(config-router-af)# network 10.1.10.0/24
leaf01(config-router-af)# end
leaf01# write memory
leaf01# exit
为了让 BGP 播发 IPv6 前缀,您需要运行额外的命令来激活 IPv6 地址族下的 BGP 邻居。Cumulus Linux 默认启用 IPv4 地址族;您无需为 IPv4 路由交换运行 activate
命令。
cumulus@leaf01:~$ sudo vtysh
...
leaf01# configure terminal
leaf01(config)# router bgp 65101
leaf01(config-router)# bgp router-id 10.10.10.1
leaf01(config-router)# neighbor swp51 interface remote-as external
leaf01(config-router)# address-family ipv6 unicast
leaf01(config-router-af)# neighbor swp51 activate
leaf01(config-router-af)# network 2001:db8::1/128
leaf01(config-router-af)# end
leaf01# write memory
leaf01# exit
vtysh 命令将配置保存在 /etc/frr/frr.conf
文件中。例如:
cumulus@leaf01:~$ sudo cat /etc/frr/frr.conf
...
router bgp 65101
bgp router-id 10.10.10.1
neighbor swp51 interface remote-as external
!
address-family ipv4 unicast
network 10.10.10.1/32
network 10.1.10.0/24
exit-address-family
...
cumulus@spine01:~$ sudo vtysh
...
spine01# configure terminal
spine01(config)# router bgp 65199
spine01(config-router)# bgp router-id 10.10.10.101
spine01(config-router)# neighbor swp1 interface remote-as external
spine01(config-router)# address-family ipv4
spine01(config-router-af)# network 10.10.10.101/32
spine01(config-router-af)# end
spine01# write memory
spine01# exit
为了让 BGP 播发 IPv6 前缀,您需要运行额外的命令来激活 IPv6 地址族下的 BGP 邻居。Cumulus Linux 默认启用 IPv4 地址族;您无需为 IPv4 路由交换运行 activate
命令。
cumulus@spine01:~$ sudo vtysh
...
spine01# configure terminal
spine01(config)# router bgp 65199
spine01(config-router)# bgp router-id 10.10.10.101
spine01(config-router)# neighbor swp1 interface remote-as external
spine01(config-router)# address-family ipv6 unicast
spine01(config-router-af)# neighbor swp1 activate
spine01(config-router-af)# network 2001:db8::101/128
spine01(config-router-af)# 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
neighbor swp1 interface remote-as external
!
address-family ipv4 unicast
network 10.10.10.101/32
exit-address-family
...
验证配置
要验证交换机是否可以看到其 BGP 邻居,请运行 vtysh show ip bgp summary
命令
cumulus@leaf01:mgmt:~$ sudo vtysh
...
leaf01# show ip bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 10.10.10.1, local AS number 65101 vrf-id 0
BGP table version 16
RIB entries 15, using 2880 bytes of memory
Peers 2, using 40 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
spine01(swp51) 4 65199 599 603 0 0 0 00:29:35 6 8 N/A
spine02(swp52) 4 65199 582 585 0 0 0 00:28:43 3 8 N/A
Total number of neighbors 2
cumulus@spine01:mgmt:~$ sudo vtysh
...
spine01# show ip bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 10.10.10.101, local AS number 65199 vrf-id 0
BGP table version 7
RIB entries 13, using 2496 bytes of memory
Peers 4, using 79 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
leaf01(swp1) 4 65101 637 634 0 0 0 00:31:20 4 7 N/A
leaf02(swp2) 4 65102 639 636 0 0 0 00:31:25 4 7 N/A
swp3 4 0 0 0 0 0 0 never Idle 0 N/A
leaf04(swp4) 4 65104 636 635 0 0 0 00:31:23 1 7 N/A
Total number of neighbors 4
要验证您是否可以在路由表中看到其他邻居的前缀,请运行 vtysh show ip route
命令。
cumulus@leaf01:mgmt:~$ sudo vtysh
...
leaf01# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, A - Babel, D - SHARP, F - PBR, f - OpenFabric,
Z - FRR,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
C>* 10.1.10.0/24 is directly connected, vlan10, 00:36:43
C>* 10.1.20.0/24 is directly connected, vlan20, 00:36:43
C>* 10.1.30.0/24 is directly connected, vlan30, 00:36:43
C>* 10.10.10.1/32 is directly connected, lo, 00:38:34
B>* 10.10.10.2/32 [20/0] via fe80::4ab0:2dff:fe51:3d2a, swp52, weight 1, 00:32:23
* via fe80::4ab0:2dff:feb1:8706, swp51, weight 1, 00:32:23
B>* 10.10.10.4/32 [20/0] via fe80::4ab0:2dff:fe51:3d2a, swp52, weight 1, 00:32:19
* via fe80::4ab0:2dff:feb1:8706, swp51, weight 1, 00:32:19
B>* 10.10.10.101/32 [20/0] via fe80::4ab0:2dff:feb1:8706, swp51, weight 1, 00:33:18
B>* 10.10.10.102/32 [20/0] via fe80::4ab0:2dff:fe51:3d2a, swp52, weight 1, 00:32:2
cumulus@spine01:mgmt:~$ sudo vtysh
...
spine01# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, A - Babel, D - SHARP, F - PBR, f - OpenFabric,
Z - FRR,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
B>* 10.1.10.0/24 [20/0] via fe80::4ab0:2dff:fe90:b5c8, swp2, weight 1, 00:37:24
B>* 10.1.20.0/24 [20/0] via fe80::4ab0:2dff:fe90:b5c8, swp2, weight 1, 00:37:24
B>* 10.1.30.0/24 [20/0] via fe80::4ab0:2dff:fe90:b5c8, swp2, weight 1, 00:37:24
B>* 10.10.10.1/32 [20/0] via fe80::4ab0:2dff:feb5:d65e, swp1, weight 1, 00:37:20
B>* 10.10.10.2/32 [20/0] via fe80::4ab0:2dff:fe90:b5c8, swp2, weight 1, 00:37:24
B>* 10.10.10.4/32 [20/0] via fe80::4ab0:2dff:fea4:fab6, swp4, weight 1, 00:37:22
C>* 10.10.10.101/32 is directly connected, lo, 00:37:31