Configure routes (2)

Last updated Oct 15, 2026 Magic Transit Virtual Network uses a routing table to steer your traffic from Cloudflare's global network to your connected networks via next-hop. You can add entries to the Magic Transit Virtual Network routing table through static route configuration or routes learned from BGP peering over IPsec and GRE tunnels or CNI with Dataplane v2 (closed beta).

Refer to Traffic Steering for more information about all the technical aspects related to:

  • Routes' priorities and weights
  • Regional scoping of traffic to reduce latency
  • BGP peering

Anycast routing

Cloudflare uses anycast to route traffic. Anycast is a network addressing and routing method that routes incoming requests to different locations. Traffic can arrive at a different geographic location than expected. Not all requests go to the closest data center because Internet routing and peering relationships are complex, and Cloudflare optimizes for performance and reliability.

One page for all your routes

The dashboard Routes page shows the routes for all of your connectors — including Cloudflare Tunnel and Cloudflare Mesh — in a single table, not just Magic Transit static routes. The following steps cover Magic Transit static routes. Routes for other connector types appear in the same table and can be filtered by type.

Configure static routes

Create a static route

  1. Go to the Routes page.

Go to Routes ↗

  1. From the Routes tab, select Create route, then choose WAN as the route type.
  2. Enter a descriptive name for your route in Description.
  3. In Prefix, enter your range of IP addresses. For example, 10.10.10.100/24.
  4. In Tunnel/Next hop, select a tunnel for your route from the tunnels you created in Configure tunnel endpoints.
  5. Choose the Priority for your route. Lower numbers have higher priorities.

Note

Cloudflare routing applies longest-prefix match. A more specific static route (like /30) always takes precedence over a less specific one (like /29), regardless of tunnel priority — unless you remove the more specific route. Keep this in mind when configuring priorities for your routes. Refer to Route prioritization for more information. 7. (Optional) Choose a Weight for your route. Refer to Set priority and weights for static routes for examples. 8. (Optional) If you need to scope your route to a specific region, you can do it in Region code. 9. (Optional) We highly recommend testing your route before adding it by selecting Test routes. 10. Select Add routes.

Note

You will need your account ID and API token to use the API.

Create a POST request using the API to create one or more static routes.

Example:

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

  • <code>Magic WAN Write</code>
  • <code>Magic Transit Write</code>

</details>

Create a Routebash

curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/routes" \
    --request POST \
    --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    --json '{
        "nexthop": "<IP_NEXT_HOP>",
        "prefix": "<YOUR_IP_PREFIX>",
        "priority": 0,
        "id": "023e105f4ecef8ad9ca31a8372d0c353",
        "description": "<ROUTE_DESCRIPTION>",
        "scope": {
                "colo_names": [
                        "den01"
                ],
                "colo_regions": [
                        "APAC"
                ]
        },
        "weight": 0
    }'
{
  "errors": [
    {
      "code": 1000,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message"
    }
  ],
  "result": {
    "routes": [
      {
        "nexthop": "203.0.113.1",
        "prefix": "192.0.2.0/24",
        "priority": 0,
        "id": "023e105f4ecef8ad9ca31a8372d0c353",
        "description": "New route for new prefix 203.0.113.1",
        "scope": {
          "colo_names": [
            "den01"
          ],
          "colo_regions": [
            "APAC"
          ]
        },
        "weight": 0
      }
    ]
  },
  "success": true
}

Edit a static route

  1. From the Routes tab, locate the route to modify.
  2. Select the three dots next to it > Edit.
  3. Enter the updated route information.
  4. (Optional) We highly recommend testing your route before adding it by selecting Test routes.
  5. Select Edit routes.

Note

You will need your account ID and API token to use the API.

Create a PUT request using the API to update one or more static routes.

Example:

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

  • <code>Magic WAN Write</code>
  • <code>Magic Transit Write</code>

</details>

Update Routebash

curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/routes/$ROUTE_ID" \
    --request PUT \
    --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    --json '{
        "nexthop": "<IP_NEXT_HOP>",
        "prefix": "<YOUR_IP_PREFIX>",
        "priority": 0,
        "id": "023e105f4ecef8ad9ca31a8372d0c353",
        "description": "<ROUTE_DESCRIPTION>",
        "scope": {
                "colo_names": [
                        "den01"
                ],
                "colo_regions": [
                        "APAC"
                ]
        },
        "weight": 0
    }'
{
  "errors": [
    {
      "code": 1000,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message"
    }
  ],
  "result": {
    "modified": true,
    "modified_route": {
      "nexthop": "203.0.113.1",
      "prefix": "192.0.2.0/24",
      "priority": 0,
      "id": "023e105f4ecef8ad9ca31a8372d0c353",
      "description": "New route for new prefix 203.0.113.1",
      "scope": {
        "colo_names": [
          "den01"
        ],
        "colo_regions": [
          "APAC"
        ]
      },
      "weight": 0
    }
  },
  "success": true
}

Delete static route

  1. From the Routes tab, locate the static route to delete.
  2. Select the three dots next to it > Delete.
  3. Confirm the action by selecting the checkbox and select Delete.

Note

You will need your account ID and API token to use the API.

Create a DELETE request using the API to delete a static route.

Example:

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

  • <code>Magic WAN Write</code>
  • <code>Magic Transit Write</code>

</details>

Delete Routebash

curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/routes/$ROUTE_ID" \
    --request DELETE \
    --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
{
  "errors": [
    {
      "code": 1000,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message"
    }
  ],
  "result": {
    "deleted": true,
    "deleted_route": {
      "nexthop": "203.0.113.1",
      "prefix": "192.0.2.0/24",
      "priority": 0,
      "id": "023e105f4ecef8ad9ca31a8372d0c353",
      "description": "New route for new prefix 203.0.113.1",
      "scope": {
        "colo_names": [
          "den01"
        ],
        "colo_regions": [
          "APAC"
        ]
      },
      "weight": 0
    }
  },
  "success": true
}

Configure BGP routes

BGP peering is available when using the following on-ramps:

Choose an ASN for BGP peering

The Magic Transit Virtual Network routing table is managed by the customer. You can select both the Cloudflare-side ASN (Autonomous System Number) and the ASN for your customer device. The customer device ASN can be 2-byte or 4-byte. Public ASNs used for Magic Transit are verified during the onboarding process.

By default, each BGP peering session uses the same Cloudflare-side ASN to represent peering with the Magic Transit Virtual Network routing table. This ASN is called the CF Account ASN and is set to 13335. You can configure this to a private 2-byte ASN (any value between 64512 and 65534, such as 65000).

The CF Account ASN applies to all BGP sessions in your account, over both IPsec/GRE tunnels and CNI. It must be different from the customer device ASN on each tunnel.

To set this ASN:

  1. Go to the Routes page. Go to Routes ↗
  2. Select WAN configuration.
  3. In CF Account ASN, enter Cloudflare's ASN.
  4. Select Update.

Create a PUT request to update the BGP settings for your account. The following example sets the CF Account ASN to 65000:

Update BGP Settingsbash

curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/bgp/settings" \
    --request PUT \
    --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    --json '{
        "cloudflare_asn": 65000
    }'

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.

Set up BGP peering

You need to configure two ASNs:

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