Skip to content
AnswerWell geo Documentation

Research · 10 min read · Answerwell

Gateway Policy Selectors, Egress Routing, and On-Ramp Matching

How Cloudflare Gateway matches traffic with selectors, routes egress by hostname or identity, and applies HTTP actions.

This page summarizes Cloudflare documentation on Cloudflare Gateway traffic policies: how selectors and wirefilter expressions match DNS, HTTP, network, resolver, firewall, and egress traffic; how Traffic Source and Traffic Destination distinguish on-ramps and off-ramps; and how egress policies choose dedicated or anchored source IPs. It is aimed at administrators who need allowlists, SaaS tenant control, or different rules for WARP versus PAC traffic without treating every changelog entry as a checklist.

Gateway policies use a wirefilter-based expression language to match traffic against selectors. The syntax is similar to, but distinct from, the Rules language used by WAF and other Cloudflare products.

Gateway policies use a wirefilter-based expression language to match traffic against selectors (criteria). This syntax is similar to, but distinct from, the Rules language used by WAF, Rules, and other Cloudflare products.

— Cloudflare, Gateway policy expressions

Each policy type has its own fields and selector list. Common prefixes include dns. for DNS policies, http. for HTTP, net. for network and egress, identity. for user context, and device_posture. for device health signals described in Traffic controls.

Policy type Field prefix Example fields
DNS dns. dns.fqdn, dns.content_category, dns.src_ip
HTTP http. http.request.host, http.request.uri, http.request.domains
Network net. net.dst.ip, net.dst.port, net.src.ip
Identity identity. identity.email, identity.groups, identity.name
Device posture device_posture. device_posture.checks.passed

When users connect through the Cloudflare One Client, Gateway can combine network selectors with identity (email, groups, authentication method) and device posture (encryption, OS version, and similar checks). Policy changes may take up to 60 seconds to propagate across Cloudflare data centers, as noted in Traffic controls.

Traffic Source selector: policies by how traffic enters Gateway

Section titled “Traffic Source selector: policies by how traffic enters Gateway”

Traffic Source answers “how did this flow reach Gateway?” so you can write different HTTP or network rules for WARP, a proxy PAC endpoint, or an MCP portal.

Gateway HTTP and Network policies now include a Traffic Source selector that identifies how traffic reaches Cloudflare. This allows administrators to write policies that target specific on-ramp methods - for example, applying different rules to traffic arriving via the Cloudflare One Client compared to traffic routed through an MCP portal or a proxy endpoint.

— Cloudflare, Traffic Source selector in Gateway policies

In the API, the field is net.onramp.type in both HTTP and network policies. Example: net.onramp.type == "device_client".

UI name API value Description
Device client device_client Traffic from the Cloudflare One Client (WARP)
Mesh mesh Traffic from a Cloudflare Mesh connector
Cloudflare WAN cloudflare_wan Traffic from Cloudflare WAN (Magic WAN)
Clientless RDP clientless_rdp Traffic from a clientless RDP session
Proxy endpoint proxy_endpoint Traffic from a proxy endpoint (PAC file)
Clientless Browser Isolation agentless_biso Traffic from clientless Browser Isolation
MCP portal mcp_portal Traffic from an MCP portal

HTTP and network selector references: HTTP policies and Network policies. On-ramps such as proxy endpoints and Cloudflare WAN can carry traffic without a logged-in WARP user, so identity-based policies may not apply unless users use the Cloudflare One Client or clientless isolation, as explained in Non-identity on-ramps.

Traffic Destination selector: policies by how traffic leaves Gateway

Section titled “Traffic Destination selector: policies by how traffic leaves Gateway”

Traffic Destination targets the off-ramp: public Internet, Cloudflare Tunnel, WAN, mesh, or device-to-device via the Cloudflare One Client.

Gateway HTTP and Network policies now include a Traffic Destination selector that identifies how traffic exits Cloudflare. This allows administrators to write policies that target specific off-ramp methods - for example, applying different rules to traffic destined for the public Internet compared to traffic routed through Cloudflare Tunnel or Cloudflare WAN.

— Cloudflare, Traffic Destination selector in Gateway policies

API field: net.offramp.type. Example: net.offramp.type == "internet".

UI name API value Description
Internet internet Traffic to the public Internet
Cloudflare WAN cloudflare_wan Traffic through a Cloudflare WAN connection
Cloudflare Tunnel cloudflare_tunnel Traffic to a private origin through Cloudflare Tunnel
Cloudflare One Client device_client Traffic to another device running the Cloudflare One Client
Mesh mesh Traffic through a Cloudflare Mesh node

Together, Traffic Source and Traffic Destination let you express paths like “WARP users hitting the public Internet” versus “PAC traffic bound for a tunnel,” without duplicating IP lists.

OIDC Claims selector: identity-based DNS, firewall, resolver, and egress

Section titled “OIDC Claims selector: identity-based DNS, firewall, resolver, and egress”

Gateway can match custom OIDC claims from your identity provider across firewall, resolver, and egress policy types—not only when users authenticate to Access applications.

Cloudflare Gateway now supports OIDC Claims as a selector in Firewall, Resolver, and Egress policies. Administrators can use custom OIDC claims from their identity provider to build fine-grained, identity-based traffic policies across all Gateway policy types.

— Cloudflare, OIDC Claims filtering

Documented uses include filtering DNS, HTTP, and network firewall traffic by claim value; sending DNS queries to specific resolvers based on claims; and assigning dedicated egress IPs from claim attributes (for example department=engineering). You configure claims on the IdP, then use the OIDC Claims selector in the policy builder. Custom claims also flow in Access OIDC SaaS setups when the profile scope is included, as described in Generic OIDC application.

Egress policies: dedicated IPs, BYOIP, and hostname-based routing

Section titled “Egress policies: dedicated IPs, BYOIP, and hostname-based routing”

Egress policies decide which source IP (or path) user traffic uses when it leaves Cloudflare. Selectors include application, source internal IP, virtual network, and—when prerequisites are met—host, domain, content categories, and application by hostname.

Enterprise customers can use Cloudflare dedicated egress IPs or Bring Your Own IP (BYOIP) IPv4/IPv6 prefixes after onboarding:

Admins can now onboard and use their own IPv4 or IPv6 prefixes to egress traffic from Cloudflare, delivering greater control, flexibility, and compliance for network traffic.

— Cloudflare, Gateway BYOIP Dedicated Egress IPs

In Gateway → Egress policies, under Select an egress IP, choose Use dedicated egress IPs (Cloudflare or BYOIP) and pick the address from the dropdown.

Administrators can steer egress IP by destination FQDN using Host, Domain, Content Categories, and Application selectors in the egress builder (beta):

Cloudflare One administrators can now control which egress IP is used based on a destination’s fully qualified domain name (FDQN) within Gateway Egress policies.

— Cloudflare, FQDN Filtering For Gateway Egress Policies

During beta, these selectors work for traffic on-ramped via the WARP client, proxy endpoints (PAC), or Browser Isolation; WARP needs extra configuration per Cloudflare’s WARP client documentation linked from that changelog. The goal is to pin egress only where an upstream app requires a fixed IP while other traffic uses a more performant default path.

Why host-based egress needs a two-step DNS mapping

Section titled “Why host-based egress needs a two-step DNS mapping”

Egress policies evaluate at Layer 4, where only IPs are visible—not hostnames. For Application, Content Categories, Domain, and Host selectors, Gateway uses a two-step process documented in Host selectors:

  1. On a matching DNS query, Gateway returns a temporary initial resolved IP (default IPv4 range 172.64.128.0/20, or a custom range if needed).
  2. When connections arrive to that temporary IP, Gateway maps them to the hostname, applies the egress policy, then rewrites the destination to the real IP before forwarding.

Turn on Allow egress policy host selectors under Zero Trust → Traffic policies → Traffic settings, or PATCH account Gateway configuration with host_selector.enabled: true (example curl in Host selectors).

Requirements and limits worth remembering:

  • Traffic and DNS mode on the Cloudflare One Client for affected flows; minimum client versions are listed in Host selectors (desktop 2025.4.929.0 or later, with Split Tunnel / doh_in_tunnel adjustments as documented).
  • DNS-only locations (IPv4/IPv6/DoT/DoH to Gateway without the client path) do not get the initial resolved IP, so host selectors do not apply.
  • DNS Override policies bypass initial resolved IP mapping for matching domains.
  • HTTPS DNS record types are unsupported for host mapping; use IP-based selectors such as destination IP instead.
  • Host, domain, and related selectors resolve the destination IP when Gateway processes the DNS query, not at egress apply time. If resolved IP and egress IP regions differ, geo-restricted destinations may fail—see Egress policies (selector prerequisites).

Enterprise DNS policies can pair with egress to control IPv4 versus IPv6 to destinations; optionally use the Domain selector per site. To force the chosen IP version, turn off Modify Gateway block behavior, as noted in Common policies.

Source IP anchoring through Cloudflare Tunnel

Section titled “Source IP anchoring through Cloudflare Tunnel”

When a SaaS or partner allowlists a non-Cloudflare IP you already own (for example AWS), you can route user traffic through cloudflared so it exits with that IP—source IP anchoring—instead of buying dedicated Cloudflare egress:

If a non-Cloudflare IP (for example, an IP from your ISP or a cloud provider like AWS) is already on their allowlist, you can route traffic through a Cloudflare Tunnel so that it exits using that same IP. This is called source IP anchoring — it allows you to keep your existing egress IPs without purchasing Cloudflare dedicated egress IPs.

— Cloudflare, Egress through Cloudflare Tunnel

The walkthrough (WARP → Gateway → tunnel → your cloud egress → Internet) is in the same document; background on migrating from backhauled static IPs is in Source IP anchoring. For Magic WAN destinations, Gateway may show egress from Cloudflare One Client virtual IPs (CGNAT) rather than public Cloudflare IPs, per Cloudflare WAN changelog.

HTTP policies: headers, redirect, block pages, and tenant control

Section titled “HTTP policies: headers, redirect, block pages, and tenant control”

On Allow actions, Gateway can add, overwrite, or delete request headers using static values or dynamic variables:

Cloudflare Gateway now supports advanced header control on Allow policies. Administrators can add, overwrite, or delete headers on matching requests using static values or dynamic variables.

— Cloudflare, New header control options for Gateway HTTP policies

This power is commonly used for tenant control: inject vendor-specific headers so corporate SaaS tenants are allowed and personal accounts are rejected—patterns for Microsoft 365, Google Workspace, Slack, Dropbox, ChatGPT, and Claude are tabulated in SaaS tenant control. Example for ChatGPT Business: Allow on Application ChatGPT with header Chatgpt-Allowed-Workspace-Id set to your workspace ID (Set policy based on approval status).

HTTP policies support a Redirect action to any URL, with optional preservation of the original URL and query string and optional policy context in query parameters. Block actions can send users to a custom block page redirect URL; account-level defaults can be overridden in DNS or HTTP policies, with policy context passed in the URL. Details are in HTTP redirect and custom block page redirect.

Gateway rule builder: wirefilter and policy preview

Section titled “Gateway rule builder: wirefilter and policy preview”

The redesigned Gateway rule builder aligns with the Access policy builder: clearer UI states, direct wirefilter editing, and a preview graphic to review policy impact before deployment.

The Gateway rule builder now features a redesigned user experience, bringing it in line with the Access policy builder experience. Improvements include: Streamlined UX with clearer states and improved user interactions; Wirefilter editing for viewing and editing Gateway rules directly from wirefilter expressions; Preview state to review the impact of your policy in a simple graphic.

— Cloudflare, New, streamlined creation experience

For ongoing product updates, see the Gateway changelog.

  • Expecting hostname egress matching from DNS locations only — without WARP Traffic and DNS mode and host-selector setup, Gateway will not issue initial resolved IPs; traffic uses default egress (Host selectors).
  • Ignoring regional DNS resolution — host-based egress resolves at DNS time; mismatched egress and destination regions can break allowlisted SaaS (Egress policies).
  • Applying identity policies on PAC or WAN on-ramps — without a user context on-ramp, use network or application criteria instead (Non-identity on-ramps).
  • Treating WAF expression docs as Gateway — wrong field names and selectors; use Gateway-specific pages (Gateway policy expressions).
  • URL selector case sensitivity — HTTP policies using the URL selector are case-sensitive (HTTP policies).

Infrastructure SSH or RDP to private targets is filtered by Gateway network policies plus Access policies for the application (SSH with Access for Infrastructure); that path is separate from public Internet egress tuning but uses the same network selector vocabulary.

  1. In the Cloudflare dashboard, confirm Allow egress policy host selectors is enabled if you rely on Host or Domain egress rules, then verify WARP Traffic and DNS mode and Split Tunnel settings match Host selectors.
  2. Create or edit a test HTTP policy using Traffic Source device_client and use the rule builder preview state (Gateway rule builder) before wide rollout.
  3. For a hostname that should use a dedicated or BYOIP egress IP, resolve DNS through Gateway and confirm connections briefly target the documented initial resolved range, then reach the real destination; compare egress IP seen by the upstream app against your BYOIP or tunnel anchoring design.
  4. Review Gateway changelog for selector beta labels (for example FQDN egress) that affect your client on-ramps.
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match your dashboard or API behavior, email yimasynthetic@gmail.com with the page URL and the exact sentence you believe is wrong, and we will clarify or correct it.