Cloudflare Docs
Magic-Transit
Visit Magic Transit on GitHub
Set theme to dark (⇧+D)

Configure static routes

Magic Transit uses a static configuration to route your traffic through Generic Routing Encapsulation (GRE) tunnels from Cloudflare’s edge to your data centers.

You must assign a route priority to each GRE tunnel–subnet pair in your GRE configuration using the following guidelines:

  • Lower values have greater priority.
  • When the priority values for prefix entries match, Cloudflare uses equal-cost multi-path (ECMP) packet forwarding to route traffic. You can refer to an example of this scenario with the 103.21.244.0/24 subnet in the edge routing configuration example below.

You can also create and edit static routes using Magic Transit Static Routes API.

Edge routing configuration example
GRE tunnel Subnet Priority
GRE_1_IAD 103.21.244.0/24 100
GRE_2_IAD 103.21.244.0/24 100
GRE_3_ATL 103.21.244.0/24 100
GRE_4_ATL 103.21.244.0/24 100
GRE_1_IAD 103.21.245.0/24 200
GRE_2_IAD 103.21.245.0/24 200
GRE_3_ATL 103.21.245.0/24 100
GRE_4_ATL 103.21.245.0/24 100

For more on how Cloudflare uses ECMP packet forwarding, refer to Traffic steering .

Map route prefixes smaller than /24

You must provide your prefixes and the tunnels they should be mapped to in order for Cloudflare to route your traffic from the edge to your data centers via GRE tunnels. Use the table below as reference.

Prefix GRE Tunnel
103.21.244.0/29 GRE_1_IAD
103.21.244.8/29 GRE_2_ATL

The minimum advertising prefix is /24, but because Cloudflare uses GRE tunnels as an outer wrapper for your traffic, we can route prefixes within that /24 to different tunnel end points.

For example, you can send x.x.x.0/29 to Datacenter 1 and x.x.x.8/29 to Datacenter 2. This is helpful when you operate in an environment with constrained IP resources.

Create a static route

  1. Log in to your Cloudflare dashboard and select Magic Transit.
  2. Next to Static routes configuration, click Configure.
  1. Click the Static Routes tab and click Create to add a new route.
  2. Enter the information for your route.
  3. (Optional) We highly recommend testing your route before adding it by clicking Test routes.
  4. If your test was successful, click Add routes when you are done.

Edit a static route

  1. After navigating to the Edit static routes page, click Edit next to the route you want to modify.
  2. (Optional) We highly recommend testing your route before adding it by clicking Test routes.
  3. Enter the updated route information and click Edit routes when you are done.

Delete static route

  1. From Static Routes, locate the static route you want to modify and click Delete.
  2. Confirm the action by selecting the checkbox and clicking Delete.