Configure routes
Last updated Oct 15, 2026 Cloudflare 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 Cloudflare 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
- Automatic Return Routing (ARR)
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 Cloudflare WAN static routes. The following steps cover Cloudflare WAN static routes. Routes for other connector types appear in the same table and can be filtered by type.
Configure static routes
The following IPv4 address ranges are allowed in the Cloudflare Virtual Network routing table:
- RFC 1918 ↗︎ address space, specifically
10.0.0.0/8,172.16.0.0/12, and192.168.0.0/16.
When using Cloudflare WAN and Cloudflare Tunnel together, consider the IP ranges utilized in the static routes of Cloudflare Tunnel when selecting static routes for Cloudflare WAN. For more information, refer to Cloudflare Tunnel.
For prefixes outside RFC 1918, contact your Cloudflare customer service manager.
Create a static route
- Go to the Routes page. Go to Routes ↗
- From the Routes tab, select Create route, then choose WAN as the route type.
- Enter a descriptive name for your route in Description.
- In Prefix, enter your range of IP addresses. For example,
10.10.10.100/24. - In Tunnel/Next hop, select a tunnel for your route from the tunnels you created in Configure tunnel endpoints.
- 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
- From the Routes tab, locate the route to modify.
- Select the three dots next to it > Edit.
- Enter the updated route information.
- (Optional) We highly recommend testing your route before adding it by selecting Test routes.
- 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
- From the Routes tab, locate the static route to delete.
- Select the three dots next to it > Delete.
- 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 Automatic Return Routing
Automatic Return Routing allows Cloudflare to track network flows from your Cloudflare WAN (formerly Magic WAN) connected locations, ensuring return traffic is routed back to the connection where it was received without requiring static or dynamic routes. This functionality requires Unified Routing mode.
To enable ARR:
- Follow the Add tunnels information to learn how to create an IPsec or GRE tunnel.
- On the tunnel's options, select Automatic return routing.
- Select Add tunnels to save your changes.
Create a POST request to create an IPsec or GRE tunnel with ARR enabled. For 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 an IPsec tunnelbash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/ipsec_tunnels" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"cloudflare_endpoint": "<CLOUDFLARE_ENDPOINT>",
"interface_address": "<INTERFACE_ADDRESS>",
"name": "IPsec_1",
"customer_endpoint": "<CUSTOMER_ENDPOINT>",
"description": "Tunnel for ISP X",
"psk": "<PSK>",
"automatic_return_routing": "true"
}'
Configure BGP routes
BGP peering is available when using the following on-ramps:
- IPsec and GRE tunnels. Requires Unified Routing.
- CNI with Dataplane v2 (closed beta and not available to new customers).
Choose an ASN for BGP peering
The Cloudflare 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.
By default, each BGP peering session uses the same Cloudflare-side ASN to represent peering with the Cloudflare 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:
- Go to the Routes page. Go to Routes ↗
- Select WAN configuration.
- In CF Account ASN, enter Cloudflare's ASN.
- 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
}'
Cloudflare WAN customers should also be aware of the following:
- The customer chooses their device ASN, which must be different from the Cloudflare-side ASN.
- The Cloudflare side ASN will be included in the
AS_PATHof announced routes to any BGP enabled on-ramp (interconnect, IPsec or GRE tunnel). - The customer-announced
AS_PATHis transitive between on-ramps — meaning the origin (customer) ASN is visible in theAS_PATHof routes received from Cloudflare via BGP. Due to default BGP loop prevention mechanisms, a router will reject any route that contains its own ASN in theAS_PATH. For example, if two Cloudflare WAN-connected sites both useASN 65000, site A will not accept routes from site B, and vice versa, because each site sees its own ASN in the advertisedAS_PATH.
To enable routing between private networks over Cloudflare WAN, you should either: - Assign a unique ASN to each site/network, or
- Configure your edge CPE to accept BGP routes that include its own ASN in the
AS_PATH.
