Skip to content

Commit 19c71bf

Browse files
committed
Added terraform and API code for the All-DNS-Domain-Allowlist rule
1 parent 0a78d47 commit 19c71bf

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

src/content/docs/learning-paths/secure-internet-traffic/build-dns-policies/recommended-dns-policies.mdx

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,54 @@ sidebar:
66

77
---
88

9-
import { Details, Render } from "~/components"
9+
import { Details, Render, Tabs, TabItem } from "~/components"
1010

1111
We recommend you add the following DNS policies to build an Internet and SaaS app security strategy for your organization.
1212

1313

1414
<Details header="All-DNS-Domain-Allowlist">
15-
15+
<Tabs syncKey="dashPlusAPI">
1616
Allowlist any known domains and hostnames. With this policy, you ensure that your users can access your organization's domains even if the domains fall under a blocked category, such as **Newly Seen Domains** or **Login Screens**.
17-
17+
<TabItem label="Dashboard">
1818
| Selector | Operator | Value | Logic | Action |
1919
| -------- | -------- | --------------- | ----- | ------ |
2020
| Domain | in list | *Known Domains* | Or | Allow |
2121
| Host | in list | *Known Domains* | | |
22-
23-
22+
</TabItem>
23+
<TabItem label="API">
24+
```sh
25+
curl --request POST \
26+
--url https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/rules \
27+
--header 'Content-Type: application/json' \
28+
--header "Authorization: Bearer <API TOKEN>" \
29+
--data '{
30+
"name": "All-DNS-Domain-Allowlist",
31+
"description": "Organization-wide whitelist. Explicitly allow resolution of these DNS domains",
32+
"precedence": 0,
33+
"enabled": false,
34+
"action": "allow",
35+
"filters": [
36+
"dns"
37+
],
38+
"traffic": "any(dns.domains[*] in $<Global Whitelist UUID>) or dns.fqdn in $<Global Whitelist UUID>"
39+
}'
40+
```
41+
</TabItem>
42+
<TabItem label="Terraform">
43+
```tf
44+
resource "cloudflare_zero_trust_gateway_policy" "dns_whitelist_policy" {
45+
account_id = var.account_id
46+
name = "All-DNS-Domain-Allowlist"
47+
description = "Organization-wide whitelist. Explicitly allow resolution of these DNS domains"
48+
precedence = 0
49+
enabled = false
50+
action = "allow"
51+
filters = ["dns"]
52+
traffic = "any(dns.domains[*] in ${"$"}${cloudflare_zero_trust_list.domain_whitelist.id}) or dns.fqdn in ${"$"}${cloudflare_zero_trust_list.domain_whitelist.id}"
53+
}
54+
```
55+
</TabItem>
56+
</Tabs>
2457
</Details>
2558

2659

@@ -120,4 +153,4 @@ Block specific IP addresses that are malicious or pose a threat to your organiza
120153
<Render file="zero-trust/blocklist-domain-host" params={{ one: "DNS" }} />
121154

122155

123-
</Details>
156+
</Details>

0 commit comments

Comments
 (0)