Implement regional private DNS servers with Gateway resolver policies
Gateway resolver policies allow you to route DNS queries to custom DNS resolvers based on various criteria. This tutorial demonstrates how to configure region-specific private DNS servers to ensure your users are directed to the closest internal resources based on their geographic location.
This approach is particularly useful for organizations with internal networks spanning multiple locations where DNS routes and manages access to private network resources.
By the end of this tutorial, you will have configured Gateway resolver policies to automatically route DNS queries to region-specific private DNS servers based on user location, providing optimal performance and access to internal resources.
This tutorial uses US and EU region servers as example private DNS servers.
Before you begin, make sure you have:
- An Enterprise Zero Trust account
- Private DNS servers deployed in multiple regions (for example, US, EU, and APAC)
- A Cloudflare Tunnel connecting your private DNS servers to Cloudflare
- Internal domains that need to be resolved (for example,
internal.example.com)
First, connect your regional private DNS servers to Cloudflare using Cloudflare Tunnel.
For each region where you have a private DNS server, create a tunnel. For each tunnel, add the private IP addresses of your DNS servers. For example, 10.0.1.53/32 for the US region and 10.1.1.53/32 for the EU region.
Repeat this process for all regional DNS servers.
Once your private DNS servers are connected to Cloudflare, configure Gateway resolver policies to route DNS queries to the appropriate regional DNS server based on user location.
For each region where you have a private DNS server:
-
Go to Traffic policies > Resolver policies.
-
Select Add a policy.
-
Name your policy based on the region (for example,
US Internal DNS). -
Create an expression to match internal domains and users in that region. For example, to match users in the United States:
Selector Operator Value Logic Domain in internal.example.comAnd Source Country IP Geolocation in United States -
In Select DNS resolver, select Configure custom DNS resolvers.
-
Enter the private IP address of your regional DNS server (for example,
10.0.1.53for US or10.1.1.53for EU). -
In the dropdown menu, choose
<IP-address> - Private. -
(Optional) Select Add DNS resolver and enter a secondary IP address to add a backup DNS resolver.
-
Select Create policy.
-
Repeat steps 1-9 for each region where you have a private DNS server. For example, to create a policy to match users in the EU region:
| Selector | Operator | Value | Logic |
|---|---|---|---|
| Domain | in | internal.example.com | And |
| Source Country IP Geolocation | in | Austria, Belgium, France, Germany, Netherlands |
Create a catch-all policy for users in regions without a dedicated DNS server, or if no policies match your traffic:
-
Go to Traffic policies > Resolver policies.
-
Select Add a policy.
-
Name your policy (for example,
Internal DNS Fallback). -
Create an expression to match internal domains:
Selector Operator Value Domain in internal.example.com -
In Select DNS resolver, select Configure custom DNS resolvers.
-
Enter the private IP address of your primary DNS server.
-
Select Create policy.
Gateway will apply resolver policies based on order of precedence. Ensure your policies are ordered from most specific to least specific:
- Go to Traffic policies > Resolver policies.
- Use the drag handle to reorder policies:
- Resolver policies with regional coverage first
- Your fallback resolver policy last
Gateway will apply the first matching policy. If no policies match your traffic, Gateway will apply the fallback resolver policy. The order between resolver policies with regional coverage does not matter.
To test your configuration, deploy WARP on a device in each region where you have a private DNS server and run a DNS query to an internal domain. For example, to test the US region:
-
Deploy WARP on a device in the US region.
-
From the device, open a terminal and run:
Terminal window nslookup internal.example.com -
Verify that the DNS query returns the expected IP address for your internal resource. The response should show the IP address that your US DNS server is configured to return for
internal.example.com. -
Repeat the test from devices in other regions to confirm they receive responses from their respective regional DNS servers. Each region may return different IP addresses based on your DNS server configuration.
- Go to Insights > Logs > DNS query logs.
- Filter for queries to
internal.example.com. - Check the Resolver IP field to confirm queries are being routed to the correct regional DNS servers based on user location.
- Use backup resolvers: Configure secondary DNS resolvers for each region to ensure high availability.
- Monitor DNS performance: Use Gateway Analytics to track DNS query performance and identify any issues with regional routing.
- Implement network policies: Combine resolver policies with network policies to control access to internal resources based on user identity and device posture.
- Consider virtual networks: If you have overlapping IP address spaces across regions, use virtual networks to isolate traffic.
- Test failover scenarios: Regularly test what happens when a regional DNS server becomes unavailable to ensure your backup resolvers work as expected.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark
-