Skip to content

Configure BGP peering

Magic Transit customers can use the Cloudflare dashboard to configure and manage BGP peering between their networks and their Magic routing table when using a Direct CNI on-ramp.

Using BGP peering with a CNI allows customers to:

  • Automate the process of adding or removing networks and subnets.
  • Take advantage of failure detection and session recovery features.

With this functionality, customers can:

  • Establish an eBGP session between their devices and the Magic Transit service when connected via CNI.
  • Secure the session by MD5 authentication to prevent misconfigurations.
  • Exchange routes dynamically between their devices and their Magic routing table.

Route distribution and convergence

Routes received from the customer device will be redistributed into the Magic routing table, which is used by both Magic WAN and Magic Transit.

All routes in the Magic routing table are advertised to BGP peers. Each BGP peer will receive each prefix route along with the full AS_PATH, with the selected Cloudflare side ASN prepended. This is so that the peer can accurately perform loop prevention.

BGP peering sessions can advertise reachable prefixes to a peer and withdraw previously advertised prefixes. This should not take more than a few minutes to propagate.

Limitations

BGP multipath is supported. If the same prefix is learned on two different interconnects then traffic destined for that prefix will be distributed across each interconnect according to the usual ECMP behavior.

BGP support currently has the following limitations:

  • The Cloudflare account ASN and the customer device ASN must be different. Only eBGP is supported.
  • Routes are always injected with a priority of 100.
  • Bidirectional Forwarding Detection (BFD) is not supported.
  • 4-byte ASNs are not supported.

Tunnel health checks

Magic Transit customers need to enable legacy bidirectional health checks alongside BGP. This is essential to determine if a specific Cloudflare datacenter is reachable from a customer device or not. Tunnel health checks will modify the route's priorities for dynamically learned BGP routes.

How to choose an ASN for BGP peering

The Magic routing table is managed by the customer, who can select both the Cloudflare-side ASN and the ASN for their customer device.

By default, each BGP peering session will use the same Cloudflare-side ASN to represent peering with the Magic Transit routing table. This default ASN is called the CF Account ASN and should be configured to a private 2-byte ASN (64512 and 65534). To set this ASN:

  1. Log in to the Cloudflare dashboard, and select your account.
  2. Go to Magic Transit > Configuration > BGP.
  3. In CF Account ASN, enter Cloudflare's ASN.
  4. Select Update.

Magic Transit customers should also be aware of the following:
  • The Cloudflare side ASN will never be exposed in AS_PATH of anycast announcements from the Cloudflare edge. In those announcements, Cloudflare will always use the Cloudflare ASN of 13335 optionally prepended with a bring-your-own ASN as described in Cloudflare ASN vs. your own ASN
  • The customer device ASN can be a private ASN or the ASN they are using for Magic Transit anycast announcements at the edge: this has no impact on the ASN for the anycast announced prefix at the edge of the Cloudflare global network.

How to set up BGP peering

You need to configure two ASNs:

  • The Cloudflare account-scoped ASN named CF Account ASN.
  • One ASN for each interconnect you want to configure with BGP.

If you already have set up your Cloudflare account ASN, you can skip steps two and three below.

  1. Log in to the Cloudflare dashboard, and select your account.
  2. Go to Magic Transit > Configuration > BGP.
  3. In CF Account ASN, enter Cloudflare's ASN.
  4. Go to Interconnects.
  5. Find the Direct CNI interconnect you want to configure with BGP > select the three dots next to it > Configure BGP.
  6. In Customer device ASN, enter the ASN for your network.
  7. In MD5 key, you can optionally enter the key for your network. Note that this is meant to prevent accidental misconfigurations, and is not a security mechanism.
  8. (Optional) In Advertised prefix list, input the additional static prefixes automatically assigned by Cloudflare during the creation of the CNI interconnect, to advertise alongside your existing routes. Leave blank if you do not want to advertise extra routes.
  9. Select Enable BGP.