Skip to content

Commit 0bd6c16

Browse files
rexscariaRex Scariamaxvp
authored
[WIP] add gateway dns request context categories selector doc (cloudflare#20896)
* add gateway dns request context categories selector doc * Add selector to list * Add common policy to page * Add additional context * Add to Allow and Block action list * Add more context * Update API call * Update src/content/docs/cloudflare-one/policies/gateway/dns-policies/index.mdx * Update src/content/docs/cloudflare-one/policies/gateway/dns-policies/common-policies.mdx --------- Co-authored-by: Rex Scaria <[email protected]> Co-authored-by: Max Phillips <[email protected]> Co-authored-by: Max Phillips <[email protected]>
1 parent 441e07b commit 0bd6c16

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

src/content/docs/cloudflare-one/policies/gateway/dns-policies/common-policies.mdx

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ head:
88
content: Common DNS policies
99
---
1010

11-
import { Render, Tabs, TabItem } from "~/components";
11+
import { Render, Tabs, TabItem, APIRequest } from "~/components";
1212

1313
The following policies are commonly used to secure DNS traffic.
1414

@@ -68,6 +68,62 @@ The categories included in this policy are not always a security threat, but blo
6868
product="cloudflare-one"
6969
/>
7070

71+
## Block a dynamic list of categories
72+
73+
You can add a list of category IDs to the [EDNS header](https://datatracker.ietf.org/doc/html/rfc6891) of a request sent to Gateway as a JSON object using OPT code `65050`. For example:
74+
75+
```json
76+
{
77+
"categories": [2, 67, 125, 133]
78+
}
79+
```
80+
81+
With the [Request Context Categories](/cloudflare-one/policies/gateway/dns-policies/#request-context-categories) selector, you can block the category IDs sent with EDNS. This is useful to filter by categories not known at the time of creating a policy, or to enforce device-specific DNS content filtering without reaching your account limit. When Gateway uses this selector to block a DNS query, the request will return an Extended DNS Error (EDE) Code 15 - Blocked error, along with a field containing an array of the matched categories.
82+
83+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
84+
85+
| Selector | Operator | Value | Action |
86+
| ------------------------ | -------- | ------- | ------ |
87+
| Request Context Category | is | _Present_ | Block |
88+
89+
</TabItem>
90+
<TabItem label="API">
91+
92+
```bash
93+
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rule \
94+
--header "Content-Type: application/json" \
95+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
96+
--data '{
97+
"name": "All-DNS-Bock-Category-Matches-In-Request",
98+
"description": "Block all category matches in the request EDNS context",
99+
"enabled": true,
100+
"action": "block",
101+
"filters": [
102+
"dns"
103+
],
104+
"traffic": "dns.categories_in_request_context_matches",
105+
"identity": ""
106+
}'
107+
```
108+
109+
</TabItem>
110+
<TabItem label="Terraform">
111+
112+
```tf
113+
resource "cloudflare_zero_trust_gateway_policy" "block_content_categories" {
114+
account_id = var.cloudflare_account_id
115+
name = "All-DNS-Bock-Category-Matches-In-Request"
116+
description = "Block all category matches in the request EDNS context"
117+
enabled = true
118+
action = "block"
119+
filters = ["dns"]
120+
traffic = "dns.categories_in_request_context_matches"
121+
identity = ""
122+
}
123+
```
124+
125+
</TabItem> </Tabs>
126+
71127
## Block unauthorized applications
72128

73129
<Render file="gateway/policies/block-applications" product="cloudflare-one" />

src/content/docs/cloudflare-one/policies/gateway/dns-policies/index.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ API value: `allow`
6363
- [Resolved Continent IP Geolocation](#resolved-continent)
6464
- [Resolved Country IP Geolocation](#resolved-country)
6565
- [Resolved IP](#resolved-ip)
66+
- [Request Context Categories](#request-context-categories)
6667
- [Security Categories](#security-categories)
6768
- [Source Continent IP Geolocation](#source-continent)
6869
- [Source Country IP Geolocation](#source-country)
@@ -114,6 +115,7 @@ API value: `block`
114115
- [Resolved Continent IP Geolocation](#resolved-continent)
115116
- [Resolved Country IP Geolocation](#resolved-country)
116117
- [Resolved IP](#resolved-ip)
118+
- [Request Context Categories](#request-context-categories)
117119
- [Security Categories](#security-categories)
118120
- [Source Continent IP Geolocation](#source-continent)
119121
- [Source Country IP Geolocation](#source-country)
@@ -392,6 +394,14 @@ Use this selector to filter based on the IP addresses that the query resolves to
392394
| ----------- | ------------------------------------------ | -------------------- |
393395
| Resolved IP | `any(dns.resolved_ips[*] == 198.51.100.0)` | After DNS resolution |
394396

397+
### Request Context Categories
398+
399+
Use this selector to match a dynamic list of [category IDs](/cloudflare-one/policies/gateway/domain-categories/#category-and-subcategory-ids) sent in the [EDNS](https://datatracker.ietf.org/doc/html/rfc6891) portion of a DNS query. Gateway includes request context with the OPT code `65050`.
400+
401+
| UI name | API example | Evaluation phase |
402+
| -------------------------- | ------------------------------------------- | --------------------- |
403+
| Request Context Categories | `dns.categories_in_request_context_matches` | Before DNS resolution |
404+
395405
### Security Categories
396406

397407
<Render file="gateway/selectors/security-categories" />

0 commit comments

Comments
 (0)