Use virtual networks to change user egress IPs
Last updated Oct 12, 2026 Note
Only available on Enterprise plans.
This tutorial gives administrators an easy way to allow their users to change their egress IP address between any of your assigned dedicated egress IP addresses. Your users can choose which egress IP to use by switching virtual networks directly from in the Cloudflare One Client.
Changing egress IPs can be useful in quality assurance (QA) and other similar scenarios in which users both use their local egress location and either switch to or simulate other remote locations.
Before you begin
Make sure you have:
- Deployed the Cloudflare One Client on your users' devices.
- Configured tunnels to connect your private network to Cloudflare. This tutorial assumes you have:
- Created two tunnels through the dashboard.
- Routed
10.0.0.0/8through one tunnel. - Routed
192.168.88.0/24through the other tunnel. - Received multiple dedicated egress IP addresses.
Create a virtual network for each egress route
First, create virtual networks corresponding to your dedicated egress IPs.
- In the Cloudflare dashboard, go to Networking > Routes. Go to Routes ↗
- In Virtual networks, select Create virtual network.
- Name your virtual network. We recommend using a name related to the location of the corresponding dedicated egress IP. For example, if your users will egress from the Americas, you can name the virtual network
vnet-AMER. - Select Save.
-
Repeat Steps 2-4 for each dedicated egress IP you want users to switch between. For example, you can create another virtual network called
vnet-EMEAfor egress from Europe, the Middle East, and Africa. -
Create a virtual network corresponding to one of your dedicated egress IPs. We recommend using a name related to the location of the corresponding dedicated egress IP. For example, if your users will egress from the Americas, you can name the virtual network
vnet-AMER.<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>Cloudflare One Networks Write</code> - <code>Cloudflare Tunnel Write</code></details>
Create a virtual networkbash
bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/teamnet/virtual_networks" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"comment": "Virtual network to egress from the Americas",
"is_default": false,
"name": "vnet-AMER"
}'
For more information, refer to Create a virtual network.
2. Repeat Step 1 for each dedicated egress IP you want users to switch between. For example, you can create another virtual network called vnet-EMEA for egress from Europe, the Middle East, and Africa.
Assign each virtual network to each tunnel
After creating your virtual networks, route your private network CIDRs over each virtual network. This ensures that users can reach all services on your network regardless of which egress IP they use.
- Go to Networking > Routes. Go to Routes ↗
- Select Create route, then choose Tunnel CIDR.
- Select the tunnel that routes
10.0.0.0/8and enter10.0.0.0/8as the network. - Under Virtual network, choose your first virtual network. For example,
vnet-AMER. - Select Create route.
- To route
10.0.0.0/8over another virtual network, repeat Steps 2-5 using a different virtual network (for example,vnet-EMEA). -
Repeat for each virtual network you created and for each private network tunnel route.
-
Assign your first virtual network to your private network route. For example, assign
vnet-AMERto your tunnel that routes10.0.0.0/8:<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>Cloudflare One Networks Write</code> - <code>Cloudflare Tunnel Write</code></details>
Update a tunnel routebash
bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/teamnet/routes/$ROUTE_ID" \
--request PATCH \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"network": "10.0.0.0/8",
"tunnel_id": "<TUNNEL_UUID>",
"virtual_network_id": "<VNET_AMER_UUID>"
}'
For more information, refer to Update a tunnel route. 2. Repeat this process for each virtual network you created. 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>Cloudflare One Networks Write</code> - <code>Cloudflare Tunnel Write</code></details>
Update a tunnel routebash
bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/teamnet/routes/$ROUTE_ID" \
--request PATCH \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"network": "10.0.0.0/8",
"tunnel_id": "<TUNNEL_UUID>",
"virtual_network_id": "<VNET_EMEA_UUID>"
}'
- Repeat Steps 1-2 for each private network tunnel route.
Each tunnel connected to your private network should have each of your virtual networks assigned to it. For example, if you have tunnels routing 10.0.0.0/8 and 192.168.88.0/24, both tunnels should have the vnet-AMER and vnet-EMEA virtual networks assigned.
| Tunnel | CIDR | Virtual network |
|---|---|---|
| Tunnel 1 | 10.0.0.0/8 |
vnet-AMER |
10.0.0.0/8 |
vnet-EMEA |
|
| Tunnel 2 | 192.168.88.0/24 |
vnet-AMER |
192.168.88.0/24 |
vnet-EMEA |
Create virtual network egress policies
Next, assign your dedicated egress IPs to each virtual network using Gateway egress policies.
- In the Cloudflare dashboard ↗︎, go to Zero Trust > Traffic policies > Egress policies.
- Select Add a policy.
- Name your policy. We recommend including the country or region traffic will egress from.
- Add the virtual network with the Virtual Network selector. For example:
| Selector | Operator | Value |
|---|---|---|
| Virtual Network | is | vnet-AMER |
| 5. In Select an egress IP, choose Use dedicated Cloudflare egress IPs. Choose the dedicated IPv4 and IPv6 addresses you want traffic to egress with. | ||
| 6. Select Create policy. | ||
| 7. Repeat Steps 1-6 to create a separate egress policy for each virtual network you created. |
- Add a Gateway egress policy that matches the corresponding virtual network. For example:
Create a Zero Trust Gateway rulebash
bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"action": "egress",
"description": "Egress via North America by connecting to vnet-AMER",
"enabled": true,
"filters": [
"egress"
],
"name": "Egress AMER vnet",
"precedence": 0,
"traffic": "net.vnet_id == <VNET_AMER_UUID>",
"rule_settings": {
"egress": {
"ipv4": "<DEDICATED_IPV4_ADDRESS>",
"ipv4_fallback": "<SECONDARY_DEDICATED_IPV6_ADDRESS>",
"ipv6": "<DEDICATED_IPV6_ADDRESS>"
}
}
}'
For more information, refer to Create a Zero Trust Gateway rule. 2. Repeat Step 1 to create an egress policy for each virtual network you created.
Each policy you create should correspond to a different primary dedicated egress IP.
Test virtual network egress
<details>
<summary>
Windows, macOS, and Linux
</summary>
- On your user's device, log in to your Zero Trust organization in the Cloudflare One Client.
- In a terminal, run the following command to check the default egress IP address.
sh
curl ifconfig.me -4
The command should output your organization's default egress IP. 3. In the client GUI, use the VNET dropdown to switch to a virtual network you created.<details><summary>
Version 2026.1 and earlier</summary>
In the Cloudflare One Client, select the gear icon > Virtual Networks.</details>
- Check the egress IP address by running <code>curl ifconfig.me -4</code> again. The command should output the IP address specified in your egress policy.
</details>
<details>
<summary>
iOS and Android
</summary>
- On your user's device, log in to your Zero Trust organization in the Cloudflare One Agent app.
- In a browser, go to <a href="https://ifconfig.me/">ifconfig.me ↗︎</a>. Your organization's default egress IP should appear in IP Address.
- In Cloudflare One Agent, go to Advanced > Connection options > Virtual networks. Choose a virtual network you created.
- Check the egress IP address by reloading the browser page from Step 1. The IP address specified in your egress policy should appear in IP Address.
</details>
While your users are connected to a virtual network, their traffic will route via the dedicated egress IP specified. You can repeat these steps to test that each virtual network is egressing from the correct IP.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/cloudflare-one/tutorials/user-selectable-egress-ips/#page","headline":"Use virtual networks to change user egress IPs","description":"This tutorial gives administrators an easy way to allow their users to change their egress IP address between any of your assigned dedicated egress IP addresses.","url":"https://developers.cloudflare.com/cloudflare-one/tutorials/user-selectable-egress-ips/","inLanguage":"en","image":"https://developers.cloudflare.com/cloudflare-one/tutorials/user-selectable-egress-ips/og.png?v=4bacf9e9102fae9d","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":["IPv4","IPv6","Private networks"]}
description: This tutorial covers how to validate that the Access JWT is on requests made to FastAPI apps. The code is written in Python. title: Validate the Access token with FastAPI image: https://developers.cloudflare.com/cloudflare-one/tutorials/fastapi/og.png?v=6aaaa7c44c65c195
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/cloudflare-one/llms.txt
Use this file to discover all available pages before exploring further.
Docs