Equinix Metal上的 BGP
Equinix Metal™ 支持边界网关协议 (BGP),用于向 Equinix Metal 服务器发布路由。我们支持同时发布 IPv4 地址和 IPv6 地址的路由。本文档概述了如何在 Equinix Metal 上使用 BGP。
步骤 1. 在项目上启用 BGP
第一步是在您的项目上启用 BGP,这将启用 BGP 会话和 BGP 会话跟踪。在项目上启用 BGP 时,您可以选择使用本地 BGP 或全局 BGP。
本地 BGP 与全局 BGP
使用本地 BGP 的主要用例是在一组服务器之间执行故障转移或 IP 地址迁移。您可以从 Equinix Metal 项目中选择一个可用的 IP 地址,并通过 BGP 从其中一台服务器发布该地址。有关如何设置和配置本地 BGP 的详细步骤,请参阅使用本地 BGP页面。
Global BGP 用于将您拥有的子网中的 IP 地址通告给 Equinix Metal,以便将您自己的 IP 地址 (BYOIP) 部署到 Equinix Metal。这需要您拥有已注册的 ASN 和 IP 地址空间。有关如何设置和配置 Global BGP 的详细步骤,请参阅 使用 Global BGP 部署 BYOIP 页面。
注意:如果您想要 BYOIP 并使用本地 BGP,请选择启用全局 BGP。如果您选择全局 BGP 并使用公有 AS,则还可以使用 BGP 会话通过本地 BGP 通告私有 IP,以便进行内部集群。
步骤 2. 发起 BGP 会话
为主机和上游路由器创建 BGP 会话。
路由概述
Equinix Metal路由器将了解您所宣传的路线并适当地将流量发送到您的服务器。
请注意, Equinix金属结构不支持向客户发布完整的 BGP 表,我们的路由器不会将路由导出给您。我们只会学习您发布的路由,并将其推送到上游。
BGP 会话通过私有 IPv4 10.x.x.x 管理网络进行管理。BGP 的必要条件是服务器上必须存在该网络及其分配的 IP 地址。
对等互连是通过两台机架顶部路由器建立的。对于 IPv4 对等互连,路由器 ID 将分别使用本地地址 169.254.255.1/32 和 169.254.255.2/32。对于 IPv6 对等互连,路由器 ID 将分别使用地址 fc00::e/128 和 fc00::f/128。由于这些路由器并非直接连接到主机,因此您可能需要配置 BGP 多跳路由,使其返回到私有 IPv4 网关地址,以便会话能够建立连接。
最重要的是,启用 BGP 后,您需要的所有特定于服务器的路由信息都可以从 服务器的元数据端点 获取。
步骤 3. 在主机上配置 BGP
在主机上配置 BGP 会宣布 IP 地址并建立 BGP 路由。
要完成 BGP 设置,您需要先将 IP 地址添加到服务器的网络接口,并在服务器上配置 BGP 路由客户端,例如 BIRD、FRR 或 ExaBGP。路由客户端将控制 BGP 会话中与Equinix Metal 上游路由器的 IP 地址公告。
更新主机网络接口
在 /etc/network/interfaces 中添加要向环回接口通告的 IP 地址。示例地址为 198.51.100.2。
cat >>/etc/network/interfaces <<EOF
auto lo:0
iface lo:0 inet static
address 198.51.100.2
netmask 255.255.255.255
EOF
然后,启动环回接口。
ifup lo:0
BGP 元数据
一旦在项目上启用了 BGP 并且启动了 BGP 会话,您就可以通过 Equinix Metal 的 元数据服务 获取配置 BGP 所需的信息。
通过 SSH 连接到服务器和 curl 元数据端点。
- IPv4 Sessions
- IPv6 Sessions
curl https://metadata.platformequinix.com/metadata | jq '.bgp_neighbors[0] | { customer_ip: .customer_ip, customer_as: .customer_as, multihop: .multihop, peer_ips: .peer_ips, peer_as: .peer_as }'
作为响应,您将获得一个包含特定于该服务器的 BGP 信息的对象,用于会话宣布 IPv4 地址。
{
"customer_ip": "10.67.50.3",
"customer_as": 65000,
"multihop": true,
"peer_ips": [
"169.254.255.1",
"169.254.255.2"
],
"peer_as": 65530
}
您可能还需要静态路由的下一跳或多跳配置的网关 IP 地址。
curl https://metadata.platformequinix.com/metadata | jq -r '.network.addresses[] | select(.public == false and .address_family == 4) | { gateway: .gateway }'
作为响应,您将获得服务器的私有 IPv4 网关地址。
{
"gateway": "10.67.50.2"
}
curl https://metadata.platformequinix.com/metadata | jq '.bgp_neighbors[1] | { customer_ip: .customer_ip, customer_as: .customer_as, multihop: .multihop, peer_ips: .peer_ips, peer_as: .peer_as }'
作为响应,您将获得一个包含特定于该服务器的 BGP 信息的对象,用于会话宣布 IPv6 地址。
{
"customer_ip": "2001:DB8:1001:100::5",
"customer_as": 65000,
"multihop": true,
"peer_ips": [
"fc00:0000:0000:0000:0000:0000:0000:000e",
"fc00:0000:0000:0000:0000:0000:0000:000f"
],
"peer_as": 65530
}
您可能还需要静态路由的下一跳或多跳配置的网关 IP 地址。
curl https://metadata.platformequinix.com/metadata | jq -r '.network.addresses[] | select(.public == false and .address_family == 4) | { gateway: .gateway }'
作为响应,您将获得服务器的私有 IPv4 网关地址。
{
"gateway": "10.67.50.2"
}
"customer_ip"- The management private IPv4 address of the server."customer_as"- The ASN of the session. If you are using Local BGP, the ASN will be the local-to-Equinix-Metal65000. If you are using Global BGP, the ASN will be your ASN."multihop"- If true, then you will need to include a multihop parameter along with static routing information in your BGP configuration."peer_ips"- An array that contains the peering IP addresses of Equinix Metal's upstream routers, these are the neighbors."peer_as"- The local ASN of the neighbor(s). On Equinix Metal, this will always be65530. This AS is stripped on export to our global peering/transit providers."gateway"- Optional information if you need to set up a static route to the upstream routers.
有关如何使用此元数据的一些示例,请参阅 Route BGP with BIRD 和 Route BGP with FRR。
示例配置
- IPv4 Sessions
- IPv6 Sessions
router bgp 65000
bgp router-id 10.66.7.1
neighbor 169.254.255.1 remote-as 65530
neighbor 169.254.255.1 description "Equinix Metal IPv4 BGP Peering"
neighbor 169.254.255.1 timers 5 15
neighbor 169.254.255.1 soft-reconfiguration inbound
neighbor 169.254.255.2 remote-as 65530
neighbor 169.254.255.2 description "Equinix Metal IPv4 BGP Peering"
neighbor 169.254.255.2 timers 5 15
neighbor 169.254.255.2 soft-reconfiguration inbound
!
address-family ipv4
network 147.75.69.232/31
neighbor 169.254.255.1 activate
neighbor 169.254.255.2 activate
exit-address-family
router bgp 65000
bgp router-id 10.66.7.1
neighbor 2604:1380:4091:4f00::1 remote-as 65530
neighbor 2604:1380:4091:4f00::1 description "Equinix Metal IPv6 BGP Peering"
neighbor 2604:1380:4091:4f00::1 timers 5 15
neighbor 2604:1380:4091:4f00::1 soft-reconfiguration inbound
neighbor 2604:1380:4091:4f00::2 remote-as 65530
neighbor 2604:1380:4091:4f00::2 description "Equinix Metal IPv6 BGP Peering"
neighbor 2604:1380:4091:4f00::2 timers 5 15
neighbor 2604:1380:4091:4f00::2 soft-reconfiguration inbound
!
address-family ipv6
network 2604:1380:4091:4f01::/64
neighbor 2604:1380:4091:4f00::1 activate
neighbor 2604:1380:4091:4f00::2 activate
exit-address-family
BGP 前缀限制
Equinix Metal强制执行每个邻居 10 个前缀的前缀限制。
如果超出限制,您需要提交支持工单(或发送邮件至support@equinixmetal.com)来重置BGP会话。如果您需要提高此限制,也可以联系支持团队。