Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

Anycast Tunnel Endpoints for GRE and IPsec: Leased IPs, Resilience, and Traffic Steering

How leased IPv4 anycast addresses work as GRE and IPsec tunnel destinations, where to find them, failover design, and route priority with ECMP.

This page summarises Cloudflare documentation for Magic Transit and Cloudflare WAN: the IPv4 anycast address Cloudflare assigns as your tunnel destination, how GRE and IPsec behave on an anycast endpoint, and how route priority, ECMP, and BGP steer traffic across multiple tunnels.

Leased Anycast IPs: what address your router tunnels to

Section titled “Leased Anycast IPs: what address your router tunnels to”

Cloudflare assigns an IPv4 anycast address to your account for use as the tunnel destination for your network’s routers. From your router’s perspective you configure one tunnel to one IP, even though that IP is reachable across Cloudflare’s global network.

Cloudflare assigns an IPv4 anycast address to your account for use as the tunnel destination for your network’s routers. You can find this address in the Cloudflare dashboard under Address Space > Leased IPs ↗︎. To request additional endpoint addresses, contact your account team.

— Cloudflare, Configure tunnel endpoints

For Magic Transit, the same location applies: Address space → Leased IPs in the dashboard (Check your Cloudflare IPs).

Default: one IPv4 anycast address on new accounts

Section titled “Default: one IPv4 anycast address on new accounts”

New Magic Transit and Cloudflare WAN accounts receive a single IPv4 anycast address by default. Extra addresses are not self-service:

New Magic Transit and Cloudflare WAN accounts are now assigned a single IPv4 anycast address by default.

— Cloudflare, New accounts assigned a single IPv4 anycast address

To request additional anycast IP addresses for your account, contact your account team.

— Cloudflare, New accounts assigned a single IPv4 anycast address

If you need several tunnels in one WAN profile but only one anycast IP, use multiple WAN connections so each WAN gets one IPsec tunnel (appliance reference).

Anycast IPs in the tunnel setup form (dashboard)

Section titled “Anycast IPs in the tunnel setup form (dashboard)”

When you add IPsec or GRE tunnels in Cloudflare WAN, the dashboard pre-loads your Anycast IPs in the tunnel configuration form—you no longer need onboarding mail or an API call for the basic address:

Cloudflare WAN now displays your Anycast IP addresses directly in the dashboard when you configure IPsec or GRE tunnels.

— Cloudflare, Anycast IPs displayed on the dashboard

No action is required. All Cloudflare WAN customers can see their Anycast IPs in the tunnel configuration form automatically.

— Cloudflare, Anycast IPs displayed on the dashboard

Tunnel steps themselves are in Configure tunnel endpoints for Cloudflare WAN and Configure tunnel endpoints for Magic Transit.

Anycast tunnel endpoints: why one IP reaches every data center

Section titled “Anycast tunnel endpoints: why one IP reaches every data center”

Anycast lets many Points of Presence share the same IP; BGP sends traffic to a nearby or preferred node:

Anycast allows multiple servers (PoPs) to share the same IP address, and the Border Gateway Protocol (BGP) routing system ensures user traffic is routed to the nearest or lowest-cost node.

— Cloudflare, DDoS protection FAQ — Global Anycast Network

For Magic Transit and Cloudflare WAN, tunnel endpoints use that model instead of fixed peer IPs:

Traditional tunnels connect two fixed endpoints — one device on each side. Magic Transit uses a different model: anycast IP addresses for Cloudflare’s tunnel endpoints. In the anycast model, any server in any Cloudflare data center can receive traffic and must be capable of encapsulating and decapsulating packets for any tunnel. This means your tunnel is not tied to a single Cloudflare server — traffic is handled by whichever data center is closest to the source.

— Cloudflare, GRE and IPsec tunnels

Magic Transit uses anycast IP addresses for its end of the network tunnel endpoints — so a single tunnel configured from a customer’s network to Cloudflare connects to all Cloudflare global data centers (excluding the China Network). This does not add strain on the router; from the router’s perspective, it is a single tunnel to a single IP endpoint.

— Cloudflare, Magic Transit Reference Architecture

GRE fits anycast because each packet is handled on its own—no shared session state across nodes:

This works with GRE tunnels because the GRE protocol is stateless. Cloudflare processes each packet independently without requiring any negotiation or coordination between tunnel endpoints. Tunnel endpoints bind to IP addresses but not to specific devices. Any device that can strip off the outer headers and then route the inner packet can handle any GRE packet sent over the tunnel.

— Cloudflare, GRE and IPsec tunnels

IPsec tunnels on anycast (IKE then global propagation)

Section titled “IPsec tunnels on anycast (IKE then global propagation)”

IPsec is stateful: your router negotiates with Cloudflare using IKE; one server completes setup, then tunnel parameters propagate so any data center can carry the tunnel:

For IPsec tunnels, the customer’s router negotiates the creation of an IPsec tunnel with Cloudflare using the Internet Key Exchange (IKE) protocol. Because IPsec is stateful (it requires shared keys and session parameters), one Cloudflare server handles the initial negotiation, then propagates the tunnel details (traffic selectors, keys, etc.) across all Cloudflare data centers. The result is that any Cloudflare server can handle traffic for that IPsec tunnel, even though only one server negotiated the setup.

— Cloudflare, GRE and IPsec tunnels

On Fortinet devices, Cloudflare’s IPsec guidance includes setting Health check type to Request and leaving Replay Protection at its default (Fortinet integration).

Resilience: Cloudflare failures vs your network failures

Section titled “Resilience: Cloudflare failures vs your network failures”

Cloudflare and your organisation divide responsibility for outage tolerance.

Cloudflare advertises your endpoint IP from many nodes. Tunnels can fail over automatically on the Cloudflare side:

Cloudflare handles failures on its network automatically by advertising your endpoint IP from multiple nodes across many globally distributed data centers.

— Cloudflare, Configure tunnel endpoints

In the event of a network outage or other issues, tunnels fail over automatically — with no impact to a customer’s network performance.

— Cloudflare, Magic Transit Reference Architecture

Failures on your network: two tunnels, two routers

Section titled “Failures on your network: two tunnels, two routers”

For your uplink or router failures, use two tunnels from separate routers to the same anycast destination:

To handle failures on your network, configure two tunnels from separate routers.

— Cloudflare, New accounts assigned a single IPv4 anycast address

The same pattern appears in Configure tunnels and third-party IPsec guides.

For high capacity, you may run multiple tunnels with equal priority; outbound traffic can spread via ECMP (appliance reference).

Traffic steering: route priority, ECMP, weights, and BGP

Section titled “Traffic steering: route priority, ECMP, weights, and BGP”

Once tunnels exist, Magic Transit and Cloudflare WAN choose a tunnel using route entry priorities and related rules (Traffic steering for Magic Transit, Traffic steering for Cloudflare WAN).

Rule Behaviour
Numeric priority Lower values = higher preference
Same prefix and priority ECMP spreads packets across equal-cost next hops
Prefix length Longest-prefix match wins (e.g. /30 over /29) regardless of tunnel priority unless you remove the more specific route
Static vs BGP, same prefix and priority Static route wins unless you deprioritise static

Cloudflare WAN steers traffic along tunnel routes based on route entry priorities.

Lower values have greater priority.

— Cloudflare, Traffic steering

Static priorities are set on the route in the dashboard or API. BGP routes enter the virtual network table at default priority 100 unless you change them with BGP communities or AS path prepending (full community list and prepend math: Traffic steering — BGP communities).

When priorities match, equal-cost multi-path (ECMP) hashing picks the tunnel per packet flow (source/destination IP; ports for TCP/UDP):

Equal-cost multi-path routing uses hashes calculated from packet ↗︎ data to determine the route chosen. The hash always uses the source and destination IP addresses. For TCP and UDP packets, the hash includes the source and destination ports as well.

— Cloudflare, Traffic steering

Implications:

  • Load sharing is per flow, not per bit—one large connection can dominate a single tunnel.
  • Weights on static routes (max 256) skew traffic among equal-priority tunnels; results are approximate (ECMP and bandwidth utilization).
  • Health-check-driven priority changes can move flows to another tunnel.

When BGP routes never win: static tie-break

Section titled “When BGP routes never win: static tie-break”

If BGP and static routes share a prefix and priority 100, only the static route is used until you change static priority (e.g. 150 or 200) or remove the static entry—see Troubleshoot routing and BGP and Routing and BGP.

Common mistakes when using Anycast tunnel endpoints

Section titled “Common mistakes when using Anycast tunnel endpoints”
  • Expecting two customer tunnels to fix Cloudflare-only issues—Cloudflare-side redundancy is already anycast; two routers address your path failures.
  • Assuming ECMP balances bandwidth evenly—it balances flows; fat TCP sessions skew utilization unless you use weights or separate design.
  • Leaving static and BGP at priority 100 for the same prefix when you intended BGP to carry traffic.
  • Multiple priority communities on one BGP update—misconfiguration; Cloudflare keeps the lowest priority value (Traffic steering).
  • Hostname private access with ECMP—breaks the requirement that DNS and data use one tunnel.
  1. In the Cloudflare dashboard, open Address space → Leased IPs and confirm the IPv4 anycast address matches what your routers use as the tunnel destination (Cloudflare IPs, Configure tunnel endpoints).

  2. For Cloudflare WAN, open the IPsec or GRE tunnel form and verify Anycast IPs appear pre-filled as documented in Anycast IPs displayed on the dashboard.

  3. Confirm two tunnels from separate routers if you designed for customer-side failover (Configure tunnel endpoints).

  4. Review static and BGP route priorities for overlapping prefixes; resolve static-vs-BGP ties using Troubleshoot routing and BGP if traffic uses the wrong path.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.