Skip to content
AnswerWell geo Documentation

Research · 9 min read · Answerwell

Advanced DDoS Protection: TCP, DNS, Prefixes and Rules

How Cloudflare Advanced DDoS Protection works for Magic Transit: TCP and DNS stateful mitigation, prefixes, rules, filters, and safe rollout.

This page summarises Cloudflare documentation on Advanced DDoS Protection for Magic Transit customers: stateful Advanced TCP Protection, Advanced DNS Protection, and optional Programmable Flow Protection. It sits alongside the Network-layer DDoS Attack Protection managed ruleset, which handles simpler L3/4 attacks; Advanced systems target highly randomized attacks that pattern-based rules miss.

When the attacks are highly randomized and DDoS managed rules are unable to detect a common pattern among the attack packets, Advanced TCP Protection uses its stateful TCP flowtracking capabilities to determine whether or not packets are legitimate.

— Cloudflare, FAQ

Advanced DDoS Protection: what the three systems do

Section titled “Advanced DDoS Protection: what the three systems do”

Advanced DDoS Protection includes Advanced TCP Protection, Advanced DNS Protection, and Programmable Flow Protection. All three use general settings (thresholds, prefixes, enablement) plus per-system rules.

System Traffic Primary attack types
Advanced TCP Protection TCP Randomized/spoofed SYN, SYN-ACK, ACK, RST floods; out-of-state TCP
Advanced DNS Protection DNS over UDP only Volumetric and random-prefix DNS attacks
Programmable Flow Protection UDP (ingress) Custom L7 UDP protocols (gaming, VoIP, streaming); eBPF programs

Advanced TCP Protection, powered by flowtrackd, is a stateful TCP inspection engine used to detect and mitigate sophisticated out-of-state TCP attacks such as randomized and spoofed ACK floods or SYN and SYN-ACK floods.

— Cloudflare, Advanced TCP Protection

Advanced DNS Protection, powered by flowtrackd, provides stateful protection against DNS-based DDoS attacks, specifically sophisticated and fully randomized DNS attacks such as random prefix attacks.

— Cloudflare, Advanced DNS Protection

Magic Transit onboarding: Monitor mode and automatic thresholds

Section titled “Magic Transit onboarding: Monitor mode and automatic thresholds”

New Magic Transit customers typically start in Monitor mode so the system can learn legitimate traffic without dropping packets.

Advanced TCP and DNS Protection systems are automatically enabled in Monitor mode with the default thresholds for new Magic Transit customers and their authorized prefixes.

— Cloudflare, General settings

Automatic thresholds are derived from the 95th percentile (P95) of observed traffic over seven days (SYN/SYN-ACK for SYN flood protection, other TCP flags for out-of-state protection, DNS over UDP for DNS protection). Calculation runs about every 10 minutes after onboarding criteria are met; Cloudflare reviews draft thresholds before they apply. Customers currently lack visibility into calculated threshold values (General settings — Limitations).

Common conclusion: Plan at least seven days of observation in monitoring mode, review Network Analytics, then move rules to mitigation (enabled) only when false positives look acceptable. If you are under attack during the learning window, contact your account team for manual thresholds (General settings — Considerations).

Prefixes: which IPs Advanced DDoS Protection covers

Section titled “Prefixes: which IPs Advanced DDoS Protection covers”

Prefixes tell Cloudflare which traffic to analyse. You must add a prefix before protection applies to sophisticated TCP attacks.

Advanced DDoS Protection protects the IP prefixes you select from sophisticated DDoS attacks. A prefix can be an IP address or an IP range in CIDR format.

— Cloudflare, Concepts — Prefixes

Eligible prefixes are either onboarded to Magic Transit or a subset of such a prefix; unapproved prefixes cannot be added (Concepts — Prefixes). You can exclude a prefix or subset so Advanced TCP Protection does not protect that range.

Allowlist: bypass inspection for trusted source IPs

Section titled “Allowlist: bypass inspection for trusted source IPs”

The allowlist lists source prefixes that bypass all configured Advanced DDoS Protection rules. Configure it under Add an IP or prefix to the allowlist.

Prefixes in the allowlist will be vulnerable to IP spoofing attacks. If an attacker can guess the source IP addresses you have allowlisted, their packets will be allowlisted.

— Cloudflare, Concepts — Allowlist

The allowlist applies to source IPs only, not your own protected prefixes (General settings — Prefixes). API bulk prefix upload supports up to 300 prefixes per request (Advanced TCP Protection API); allowlist expressions support roughly 200 IP addresses per rule expression (Add an IP or prefix to the allowlist).

Advanced TCP Protection: SYN flood and out-of-state TCP rules

Section titled “Advanced TCP Protection: SYN flood and out-of-state TCP rules”

Advanced TCP Protection offers two independent components, each needing at least one rule before you enable mitigation globally (Advanced TCP Protection):

  1. SYN Flood Protection — challenges SYN/SYN-ACK floods above configured packet-per-second thresholds when in mitigation mode.
  2. Out-of-state TCP Protection — drops out-of-state packets (e.g. randomized ACK/RST floods) that exceed thresholds and do not belong to tracked connections.

It can protect pinpointed destination IP/port attacks and broad prefix-wide attacks, and tracks connections across data centers (Advanced TCP Protection — How it works). Protected Learning (flow inference) helps legitimate flows that shift between colos after routing changes without immediately blocking them (FAQ).

Per Concepts:

Setting Meaning
Scope global, region, or datacenter; most specific scope wins when multiple apply
Mode monitoring (learn only), enabled (mitigation), or disabled
Burst sensitivity Low = larger spikes can trigger; high = smaller spikes; default Medium
Rate sensitivity Low = higher sustained rates needed; high = stricter, more false positives; default Medium

In mitigation mode, SYN flood rules will challenge new connection initiation requests (SYN, SYN-ACK) if they exceed the configured packet-per-second thresholds. The threshold should be higher than the normal rate of legitimate SYN and SYN-ACK packets that your network receives.

— Cloudflare, Advanced TCP Protection — SYN Flood Protection

Always move from Monitoring to Mitigation (Enabled); do not jump from Disabled straight to mitigation, or long-lived connections may be dropped during a new learning period (Troubleshooting Advanced TCP Protection).

Filters: override rule mode for matching traffic

Section titled “Filters: override rule mode for matching traffic”

A filter changes execution mode (monitoring, enabled, or disabled) for packets matching a Rules language expression (ip.src, ip.dst, tcp.srcport, tcp.dstport). Filters apply only to Advanced TCP Protection (Create a filter).

When both rules and filters exist, filters take precedence (Determining the execution mode):

  1. Mitigation filter (enabled)
  2. Monitoring filter (monitoring)
  3. Off filter (disabled)
  4. If no filter matches, use the rule’s mode.

A typical onboarding pattern: keep existing prefixes in mitigation while adding a monitoring filter for a new prefix (Concepts — Example use case).

Dashboard steps: Create a rule and Create a filter. API examples: Common API calls (TCP).

Advanced DNS Protection: baseline learning and profile sensitivity

Section titled “Advanced DNS Protection: baseline learning and profile sensitivity”

Advanced DNS Protection learns normal query patterns, then mitigates anomalies without blocking legitimate DNS (Advanced DNS Protection — How it works).

  • Protocol limit: analyses DNS over UDP only, not DNS over TCP.
  • Setup: create a DNS protection rule (Setup).
  • Profile sensitivity (DNS only): tolerance for queries not recently seen; default and recommended Low (Concepts — Profile sensitivity).
  • Analytics: DNS protection tab in Network Analytics shows queried domains and record types.
  • Not for DNS Firewall: use DNS Firewall for caching/proxying; Advanced DNS Protection does not apply there.

Disabling DNS-related data collection requires removing prefixes (which also removes them from Advanced TCP Protection) (Advanced DNS Protection — Data collection).

API: Advanced DNS Protection API and examples. Rule JSON fields: scope, mode, profile_sensitivity, rate_sensitivity, burst_sensitivity (JSON objects).

Programmable Flow Protection: custom UDP eBPF (beta add-on)

Section titled “Programmable Flow Protection: custom UDP eBPF (beta add-on)”

Programmable Flow Protection lets you upload C source compiled to eBPF for deep inspection of ingress UDP traffic (gaming, VoIP, financial, streaming protocols). It runs on flowtrackd, respects Advanced Protection prefixes and the allowlist, and requires Advanced DDoS Protection to be enabled (Programmable Flow Protection).

Programmable Flow Protection is currently in closed beta and available as an add-on for the Magic Transit (BYOIP or Cloudflare-leased IPs) service only.

— Cloudflare, Programmable Flow Protection (Beta)

Workflow: upload a program (dashboard or API with Content-Type: text/plain), verify status: success, then create a rule selecting program, mode (enabled, disabled, monitoring), and optional scope/expression. Rules pin to a program_version; updating program source creates a new version without moving existing rules (Programmable Flow Protection API). Safe rollout: scoped monitoring rules with narrow expressions before a global enabled rule (Safe program and rule deployment best practices).

Enable Advanced DDoS Protection: dashboard and API

Section titled “Enable Advanced DDoS Protection: dashboard and API”
  1. Advertise Magic Transit prefixes, then open L3/4 DDoS protection → DDoS Managed Rules → Advanced Protection → General settings and toggle the feature On (General settings — Enablement).

  2. Under General settings → Prefixes, add prefixes you onboarded to Magic Transit.

  3. Create global monitoring rules for SYN flood and out-of-state TCP, and a rule for Advanced DNS Protection if you receive DNS over UDP on those prefixes.

  4. After review in Network Analytics, change rule Mode from Monitoring to Mitigation (Enabled) (Verify DDoS protection).

Get started with Magic Transit recommends enabling Advanced TCP and/or DNS Protection when your network needs stateful analysis beyond managed rulesets.

Configure via the Cloudflare API base https://api.cloudflare.com/client/v4 with {account_id} (API configuration):

Enable TCP protection globally before relying on rules:

curl --request PATCH \
"https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/tcp_protection_status" \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{"enabled": true}'

(Example from Common API calls (TCP).)

False positives and mitigation reasons in Network Analytics

Section titled “False positives and mitigation reasons in Network Analytics”

If legitimate traffic is dropped, use the Mitigation reason field in the Advanced TCP Protection tab of Network Analytics (Concepts — Mitigation reasons, Troubleshooting).

Mitigation reason Typical cause First actions
Not found Incomplete learning or connections predating activation Monitoring 4+ hours, then mitigation
Unexpected ECMP — same flow hitting different colos Lower burst sensitivity per colo; escalate if persistent
Out of sequence Reordering or loss on the path Increase burst sensitivity for affected colo
Challenge needed SYN flood threshold exceeded Tune burst/rate sensitivity; check allowlist needs

If traffic shows TCP Protection as the blocking system elsewhere, add an Advanced TCP Protection allowlist entry or filter (Diagnose traffic decisions). Tune burst sensitivity before rate sensitivity (Troubleshooting Advanced TCP Protection).

For proactive readiness, Magic Transit customers should keep Advanced TCP, DNS, and (if licensed) Programmable Flow Protection enabled and tuned (Proactive DDoS defense).

  1. In the dashboard, open Verify DDoS protection steps: L3/4 DDoS protection → DDoS Managed Rules → Advanced Protection → General settings, confirm the system is On and expected prefixes appear.

  2. Under Advanced TCP Protection, confirm SYN Flood Protection and Out-of-state TCP Protection rules exist in the expected mode (Verify DDoS protection).

  3. Under Advanced DNS Protection, confirm a DNS rule exists if you serve DNS over UDP on protected prefixes (Verify DDoS protection).

  4. In Network Analytics, review the Advanced TCP, DNS, or Programmable Flow Protection tabs for monitored versus mitigated traffic and Mitigation reason values before and after mode changes (Troubleshooting Advanced TCP Protection).

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

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.