Traffic steering (3)·续2

BGP architecture

Global routing and anycast edge

Magic Transit Virtual Network makes a one-pass, per-packet routing decision at the Cloudflare data center that first processes the packet (the ingress node). This ensures that even when a packet traverses multiple nodes within the Cloudflare backbone, its path is determined at the point of entry for maximum efficiency.

Your BGP session over IPsec, GRE, or CNI is established with the Cloudflare data center closest to your BGP peer device. Routes learned here must propagate to Cloudflare's global edge to govern how traffic is routed across the entire network.

  • Convergence time: Global route convergence typically completes within 20 seconds.
  • Visibility: You can monitor learned routes and their propagation status through the Cloudflare dashboard or API.

Centralized route propagation

Magic Transit Virtual Network uses a centralized control plane for route propagation, functioning similarly to a BGP Route Reflector. This architecture decouples the physical BGP session from global route distribution:

  • Session termination: BGP peering sessions are terminated at the Cloudflare edge location closest to your router.
  • SDN conversion: Ingress BGP updates are converted into Software-Defined Networking (SDN) state and transmitted to a centralized relay function.
  • Global dissemination: The relay propagates these instructions to every Cloudflare data center globally, updating the local Forwarding Information Base (FIB) at each site.

Edge Resiliency Mode (Non-Stop Forwarding)

Cloudflare's data plane is designed for high availability. If the edge location loses communication with the centralized relay, the system enters Edge Resiliency Mode, mimicking Non-Stop Forwarding (NSF) behavior:

  • Forwarding continuity: Edge locations continue to route traffic using the last-known-good forwarding table (FIB). Data plane traffic remains uninterrupted.
  • Stale path retention: Because the FIB is frozen during this mode, forwarding decisions remain active even if the underlying BGP session with your router flaps or resets.
  • Continuous health monitoring: While BGP updates are frozen, tunnel health checks remain active. These are sent from all Cloudflare data centers, allowing the edge at any ingress node to detect if a physical connection to your router has failed. If a health check fails, the ingress node at the edge will deprioritize that specific path, preventing traffic from being sent into a black hole despite the frozen routing state.
  • Update freeze: During this state, the global control plane is frozen. New BGP updates received from your router will be held locally at the edge and will not propagate globally until connectivity to the centralized relay is restored.
  • Magic Transit edge announcement: During this frozen state, your BYOIP prefix(es) will continue to be announced at Cloudflare's global edge. You can manually change this announcement status through the API or dashboard.

Traffic persistence during BGP resets

In Edge Resiliency Mode, Cloudflare prioritizes forwarding continuity. If your on-premises router resets or the BGP session flaps, the edge will continue to forward traffic toward your peer device based on the last known valid routing state — provided that the underlying tunnel health checks remain successful.

If the BGP session resets and the tunnel health checks fail (for example, your router is completely offline), the edge will typically take alternate paths until connectivity is restored.

System recovery and re-synchronization

Once connectivity between the Cloudflare edge and the centralized relay is restored, the system automatically exits Edge Resiliency Mode and performs a stateful re-synchronization:

  1. RIB-to-relay sync: The edge pushes all currently held BGP updates (the current RIB state) to the relay.
  2. Global update: The relay reconciles these updates and propagates any changes to the rest of the Cloudflare global network.
  3. FIB unfreeze: The local forwarding tables at the edge are unfrozen and updated with the latest validated routing instructions.

BGP peering with the Magic Transit network routing table

Magic Transit BGP peering is with the Magic Transit network routing table (as opposed to peering with the Cloudflare Internet global network). BGP peers configured by following this guide will receive advertisements for all prefixes in the Magic Transit network routing table plus any additional prefixes configured in the on-ramp Advertised prefix list.

If instead you are seeking to do public peering with the Cloudflare ASN 13335 at one of the Cloudflare data centers, refer to PNI and peering setup. It is not currently possible to share Magic Transit Virtual Network BGP peering and PNI on the same physical interconnect port.

BGP route distribution and convergence

Cloudflare redistributes routes received from your device into the Magic Transit Virtual Network routing table.

All routes in the Magic Transit Virtual Network routing table are advertised to BGP peers. Each BGP peer receives 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 propagation takes no more than a few minutes.

BGP timers and settings

Cloudflare uses the following timers, which are not configurable:

Setting Description
Hold timer 240 seconds<br> (To establish a session, Cloudflare compares its hold timer and the peer's hold timer, and uses the smaller of the two values to establish the BGP session.)
Keepalive timer One third of the hold timer.
Graceful restart Helper mode only. Cloudflare advertises a restart time of 120 seconds and honors a peer restart time of up to 90 seconds.
  • Hold timer: Specifies the maximum amount of time that a BGP peer waits to receive a KEEPALIVE, UPDATE, or NOTIFICATION message before declaring the BGP session down. Cloudflare uses the smaller of this default hold timer and that received from the peer in the OPEN message.
  • Keepalive timer: BGP systems exchange keepalive messages to determine whether the peer router is reachable. If keepalive messages are not received within the hold timer, the session is assumed to be down, indicating that the peer is no longer reachable at the BGP protocol level.
  • Graceful restart timer: Tracks how long a router waits for a peer to re-establish a BGP session after the peer initiates a graceful restart. If the peer does not reconnect within this time, the router declares the session down and removes stale routes.

BGP capabilities and limitations

BGP multipath is supported. If BGP learns the same prefix on two different interconnects, Cloudflare distributes traffic destined for that prefix across each interconnect according to the usual ECMP behavior.

Cloudflare supports BGP Graceful Restart (RFC 4724 ↗︎) in helper mode only. Cloudflare never acts as the restarting speaker, because your device always initiates the BGP session.

If your device negotiates graceful restart and then restarts, Cloudflare keeps its routes as stale while it reconnects. Cloudflare removes stale routes after your device sends End-of-RIB, or after 90 seconds.

BGP support has the following limitations:

  • The Cloudflare account ASN and your device ASN must be different. Only eBGP is supported.
  • Cloudflare always injects routes with a priority of 100.
  • Bidirectional Forwarding Detection (BFD) is not supported.

For Magic Transit customers, BGP with the Magic Transit Virtual Network routing table is separated from the announcement of anycast prefixes at the Cloudflare edge. Anycast withdrawal must be controlled with existing methods documented in Advertise prefixes.

Tunnel health checks

You need to enable legacy health checks alongside BGP. This is essential to determine if a specific Cloudflare data center is reachable from your device. Tunnel health checks modify the route priorities for dynamically learned BGP routes.

Was this helpful?

YesNo

On this page

Traffic steering (3)·续2 - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/magic-transit/reference/traffic-steering/#page","headline":"Traffic steering","description":"Magic Transit uses a static configuration to route traffic through anycast tunnels using the Generic Routing Encapsulation (GRE) and Internet Protocol Security (IPsec) protocols from Cloudflare's global network to your network.","url":"https://developers.cloudflare.com/magic-transit/reference/traffic-steering/","inLanguage":"en","image":"https://developers.cloudflare.com/magic-transit/reference/traffic-steering/og.png?v=b7f6ef296db10186","dateModified":"2026-10-12","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["IPsec"]}


description: Magic Transit uses probes to check for tunnel health. Review information on this page to learn more. title: Tunnel health checks image: https://developers.cloudflare.com/magic-transit/reference/tunnel-health-checks/og.png?v=7574be019b83845e


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/magic-transit/llms.txt
Use this file to discover all available pages before exploring further.