Setup (6)
Last updated Jul 10, 2026 In order to enable automatic mitigation of random prefix attacks:
- Set up DNS Firewall.
- Enable attack mitigation on your DNS Firewall cluster.
- In the Cloudflare dashboard, go to the DNS Firewall Clusters page. Go to Clusters ↗
- Select the cluster you want to update, then select Edit.
- Turn on Attack mitigation and choose whether Cloudflare should only mitigate attacks when the upstream is unhealthy.
- Select Save.
Send a PATCH request to update your DNS Firewall cluster:<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>DNS Firewall Write</code></details>
Update DNS Firewall Clusterbash
bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/dns_firewall/$DNS_FIREWALL_ID" \
--request PATCH \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"attack_mitigation": {
"enabled": true,
"only_when_upstream_unhealthy": true
}
}'
Once you turn on attack mitigation, Cloudflare returns a REFUSED response to queries that are part of a random prefix attack.
Note
If you do not specify otherwise, Cloudflare automatically sets the only_when_upstream_unhealthy parameter to true, which means that Cloudflare will only mitigate attacks when we detect that the upstream is unresponsive (possibly as a result of an attack).
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/dns/dns-firewall/random-prefix-attacks/setup/#page","headline":"Setup","description":"Enable automatic mitigation of random prefix attacks in the Cloudflare dashboard or via the API.","url":"https://developers.cloudflare.com/dns/dns-firewall/random-prefix-attacks/setup/","inLanguage":"en","image":"https://developers.cloudflare.com/dns/dns-firewall/random-prefix-attacks/setup/og.png?v=96bb1374ef08a9cd","dateModified":"2026-07-10","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/"}}
description: Set up DNS Firewall to protect upstream nameservers from DDoS attacks and reduce load by caching DNS responses. title: Setup image: https://developers.cloudflare.com/dns/dns-firewall/setup/og.png?v=96bb1374ef08a9cd
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/dns/llms.txt
Use this file to discover all available pages before exploring further.
Docs