DNS, HTTP, and Network Traffic Policy Design and Enforcement
How Cloudflare Gateway DNS, HTTP, and network policies work together: types, order of enforcement, recommended rules, and private access patterns.
This page summarizes Cloudflare Zero Trust documentation on Gateway traffic policies—the checkpoints that control what users can resolve, connect to, and fetch on the Internet and on private networks reached through Cloudflare Tunnel or Cloudflare One Client.
Gateway traffic policies: DNS, HTTP, and network filtering explained
Section titled “Gateway traffic policies: DNS, HTTP, and network filtering explained”Gateway applies security at different layers of traffic, similar to familiar firewall roles. Traffic controls map them this way: DNS policies filter before a connection exists; network policies act like a Layer 4 firewall on TCP/UDP (and GRE); HTTP policies inspect web requests at Layer 7, including decrypted HTTPS when TLS inspection is enabled.
Every organization needs a way to control what users can reach on the Internet — blocking malware sites, restricting risky applications, and deciding how traffic exits the corporate network. Think of traffic policies as a set of security checkpoints, each inspecting a different layer of your traffic before it is allowed through.
— Cloudflare, Traffic controls
| Filtering goal | Policy type | Why |
|---|---|---|
| Block domains (all pages) | DNS | Prevents the domain from resolving |
| Block websites by URL path | HTTP | Inspects the full URL, not just the domain |
| Block non-HTTP traffic (SSH, RDP, databases) | Network | Inspects packets on IP, port, protocol; protocol detection can match SSH without relying on port 22 alone |
| Block malware and threats | DNS and HTTP | DNS blocks known-bad names; HTTP catches threats in otherwise allowed traffic |
| Drop traffic before other policies | Packet filtering | Packet filtering matches packet attributes without user context |
DNS policies work across protocols because they control lookups. HTTP policies need a root or custom certificate on devices. Network policies require the Cloudflare One Client on enrolled devices for full identity and posture integration.
DNS policies: block domains before connections start
Section titled “DNS policies: block domains before connections start”A DNS policy pairs a traffic condition (selector, operator, value) with an action. When a user sends a DNS request, Gateway matches it and may allow resolution, block it, override the answer, or apply Safe Search or YouTube Restricted Mode.
DNS policies let you control which websites and services your users can reach by inspecting their DNS queries — the lookups that translate domain names into IP addresses. Because DNS policies act at the lookup stage, they work across all protocols and applications, not just web browsers.
— Cloudflare, DNS policies
DNS actions include Allow, Block, Override, Safe Search (safesearch), and YouTube Restricted Mode (ytrestricted). Override only supports A, AAAA, and HTTPS record types; other types get REFUSED—and unlike many blocks, that case does not show a Gateway block page (non-A/AAAA types can return REFUSED with no block page).
Identity selectors (for example User Email, User Group Names) apply when devices use the Cloudflare One Client or Cloudflare One Agent. Create your first DNS policy in Zero Trust → Traffic policies → Firewall policies → DNS.
Recommended DNS policy stack
Section titled “Recommended DNS policy stack”Cloudflare’s recommended DNS policies follow a consistent pattern: high-precedence Allow rules for known-good domains, then layered blocks.
- Allowlist —
Domain/Hostin list Known Domains at low precedence so corporate names still resolve if they overlap blocked categories like “Newly seen domains.” - Security categories —
Security Categoriesin All security risks → Block (threat intelligence). - Content categories — test with Allow first to find false positives, then switch to Block per recommended DNS policies.
- Lists and geo — resolved-IP blocklists, banned countries, risky TLD regexes, and phishing keyword policies that exclude domains on your allowlist.
Lists hold hostnames, domains, or IPs reused across policies. Indicator Feeds add a Indicator Feeds selector once your account has feed access.
HTTP policies: URLs, files, TLS inspection, and Do Not Inspect
Section titled “HTTP policies: URLs, files, TLS inspection, and Do Not Inspect”HTTP policies filter HTTP and HTTPS by host, URL, application, file types, DLP profiles, and more. Default inspection covers port 80 and, with TLS decryption, port 443; HTTP/3 needs the UDP proxy.
HTTP policies allow you to filter all HTTP and HTTPS requests based on URLs, hostnames, HTTP methods, file types, and other request attributes. Unlike network policies which operate at Layer 4 (TCP/UDP), HTTP policies operate at Layer 7 and can inspect the full content of web traffic.
— Cloudflare, HTTP policies
Do Not Inspect (action: off) bypasses decryption for hosts that break inspection (common with some Google properties). Those policies are evaluated before Allow/Block regardless of list order—see order of enforcement. Bypassing inspection removes HTTP logging, blocking, DLP, and AV scanning for that traffic; network policies can still apply.
Recommended HTTP policies mirror DNS: inspection bypass list, security-risk block, content categories, domain blocklists, application blocks (for example shadow IT / AI), Browser Isolation for privileged or high-risk users, and quarantined-user restrictions.
Before switching a new rule to Block, Cloudflare suggests setting the action to Allow, reviewing Gateway logs for matches, then enabling the intended action.
Network policies: IP, port, SNI, and private applications
Section titled “Network policies: IP, port, SNI, and private applications”Network policies control TCP/UDP (and related) flows by destination IP, port, protocol, SNI, Detected Protocol, identity, and Passed Device Posture Checks.
Network policies control TCP and UDP traffic between your users and network destinations. Use them to allow or block non-HTTP traffic such as SSH, RDP, and database connections based on IP addresses, ports, and protocols.
— Cloudflare, Network policies
After DNS filtering, network filtering adds controls for RDP, SSH, databases (for example MySQL on 3306 per the MySQL network policy tutorial), and custom ports. Actions include Allow, Block, and Network Override (l4_override)—verify override destinations are reachable, or traffic can fail without useful logs.
Common network policies evaluate top to bottom; place specific Allow rules above broad Block rules. Patterns include allow only HTTP/HTTPS then block other protocols, proxy-endpoint restrictions, and employee-only private IP access with a catch-all deny.
SNI and clientless access limits
Section titled “SNI and clientless access limits”For private hostnames, SNI and SNI Domain selectors default to HTTPS on port 443. Turn on protocol detection to inspect other ports. SNI selectors apply only to Cloudflare One Client traffic; other on-ramps may need Destination IP instead—see Connect a private hostname. Device posture checks are not supported for some clientless private-DNS paths that do not use the Cloudflare One Client (clientless access tutorial).
Self-signed or private-CA TLS on internal HTTPS apps may require an HTTP Allow with untrusted-certificate Pass through when decryption is on (Error 526 otherwise), as documented on the same private hostname page.
Policy order of enforcement: what runs when
Section titled “Policy order of enforcement: what runs when”Understanding order prevents “allowed in DNS but blocked on connect” surprises and explains why blocks do not always stop the first TCP packet.
Global policies run first. Global policies include DNS resolver allowances for Cloudflare client and dashboard hostnames and HTTP bypass rules that prevent lockouts (Zero Trust dashboard, block page hosts, OCSP, Browser Isolation assets).
Within each policy family:
- DNS policies use first-match by precedence: a higher-precedence Allow beats a lower Block on the same query (DNS policies).
- HTTP policies evaluate top to bottom; Do Not Inspect is always first (common HTTP policies).
- Network policies evaluate top to bottom; first match wins (common network policies).
For proxied TCP (non-Worker paths), Gateway completes a TCP handshake to the origin before applying Allow/Block policies:
If the TCP connection to the destination server is successful, Gateway will apply policies. If Gateway policies allow the connection, Gateway will connect the user to the destination server. If Gateway policies block the connection, Gateway will end the connection and will not send any data between the user and the destination server.
— Cloudflare, Order of enforcement
So network or HTTP Block policies do not stop the initial TCP SYN from reaching the destination. Enterprise customers can use Cloudflare Network Firewall packet rules to block SYNs earlier. Failed origin connections are retried and may not appear in Gateway activity logs even though session logs exist.
Private network access: DNS plus network plus default deny
Section titled “Private network access: DNS plus network plus default deny”Default Tunnel behavior lets enrolled devices reach the whole private space. Cloudflare recommends default deny on private ranges, then explicit Allow rules.
To prevent Cloudflare One Client users from accessing your entire private network, we recommend creating a catch-all Gateway block policy for your private IP space. You can then layer on higher priority Allow policies (in either Access or Gateway) which grant users access to specific applications or IPs.
— Cloudflare, Connect an IP/CIDR
Secure your first application recommends two Gateway policies per application:
- DNS policy on application domains (identity/posture aligned)—enforcement at resolution; deny here stops the flow before connect.
- Network policy on application IPs (and optional SNI/ports)—enforcement at connect time.
Add a bottom catch-all Block on private IP lists (and optionally private apex domains via SNI). Policy design notes that customers usually mix DNS resolution, SNI, and IP groupings. Do not enable full default-deny while first testing; watch logs, then tighten (Secure your first application).
MySQL and SSH tutorials follow the same allow-then-catch-all pattern (MySQL network policy, SSH device client). Cloudflare also recommends a catch-all block at the bottom of network lists for database access.
Identity, quarantine, posture, and CIPA
Section titled “Identity, quarantine, posture, and CIPA”Identity conditions (User Email, User Group Names, SAML attributes) gate DNS, HTTP, and network rules—for example allow Social Networks only for Marketing, block for everyone else (common DNS policies). Recommended DNS and recommended network policies include Quarantined Users templates that block unless destination is on a remediation list.
Device posture integrates on network and HTTP policies (Passed Device Posture Checks). Recommended network policies include posture-fail restrictions and serial-number allowlists.
Schools using Project Cybersafe Schools often deploy a single CIPA Filter content-category block (create CIPA policy); administrators may add categories beyond the recommended set.
Timed DNS policies activate on schedules via dashboard or API schedule (timed DNS policies).
Common mistakes when building Gateway policies
Section titled “Common mistakes when building Gateway policies”- Wrong layer — Blocking a URL needs HTTP, not DNS alone; blocking SSH needs network (or protocol detection), not DNS-only rules (traffic controls).
- Precedence inversion — Corporate allowlists must sit above broad category blocks (recommended DNS policies).
- Assuming DNS block stops all traffic — Hard-coded fallback resolvers bypass DNS policy unless port
53to those IPs is blocked (DNS policies). - Default allow on private Tunnel networks — Without a private-space catch-all block, users may reach any internal IP (connect private hostname).
- SNI on non-client traffic — Use destination IP policies for clientless or non-WARP on-ramps (connect private hostname).
- Immediate Block without log review — Test with Allow first (create your first HTTP policy).
- Terraform v4 precedence hashes — May reorder unexpectedly; provider v5 or manual precedence updates via API (DNS policies).
- Filter by resolved IP category — Can increase false positives when IPs are shared (domain categories).
How to check this on your site
Section titled “How to check this on your site”- Confirm enrolled devices or locations send traffic to Gateway, then open Zero Trust → Logs → Gateway (DNS, Network, or HTTP) and verify queries and sessions appear after a test lookup or browse, per DNS filtering get started.
- Trigger a domain covered by your security-category block (or a test block rule) and confirm a block event in DNS logs; for CIPA deployments, follow create CIPA policy verification in Logs → Gateway → DNS.
- For HTTP rules, reproduce a request that should match (URL, application, or file type) and confirm the matching policy name in HTTP activity logs after TLS inspection is correctly deployed (HTTP policies).
- For private access, attempt connect as an unauthorized user and confirm the catch-all network block and the explicit allow for authorized identity; compare with Secure your first application expectations.
- You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.