Skip to content

Commit e41b92f

Browse files
committed
Add domain blocklist API calls
1 parent 29cc080 commit e41b92f

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,15 +449,45 @@ resource "cloudflare_zero_trust_gateway_policy" "dns_resolvedip_blocklist_rule"
449449
<TabItem label="API">
450450

451451
```sh
452-
452+
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules \
453+
--header "Content-Type: application/json" \
454+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN>" \
455+
--data '{
456+
"name": "All-DNS-DomainHost-Blocklist",
457+
"description": "Block specific domains or hosts that are malicious or pose a threat to your organization.",
458+
"precedence": 100,
459+
"enabled": false,
460+
"action": "block",
461+
"filters": [
462+
"dns"
463+
],
464+
"traffic": "any(dns.domains[*] in $<DOMAIN_BLOCKLIST_UUID>) and dns.fqdn in $<HOST_BLOCKLIST_UUID> and dns.fqdn matches \".*example\\.com\"",
465+
"rule_settings": {
466+
"block_page_enabled": true,
467+
"block_reason": "This domain was blocked due to being classified as a security risk to the organization"
468+
}
469+
}'
453470
```
454471

455472
</TabItem>
456473

457474
<TabItem label="Terraform">
458475

459476
```tf
460-
477+
resource "cloudflare_zero_trust_gateway_policy" "block_dns_domain_host" {
478+
account_id = var.account_id
479+
name = "All-DNS-DomainHost-Blocklist"
480+
description = "Block specific domains or hosts that are malicious or pose a threat to your organization."
481+
precedence = 100
482+
enabled = false
483+
action = "block"
484+
filters = ["dns"]
485+
traffic = "any(dns.domains[*] in ${"$"}${cloudflare_zero_trust_list.domain_blocklist.id}) and dns.fqdn in ${"$"}${cloudflare_zero_trust_list.host_blocklist.id} and dns.fqdn matches \".*example\\.com\""
486+
rule_settings = {
487+
block_page_enabled = true
488+
block_reason = "This domain was blocked due to being classified as a security risk to the organization"
489+
}
490+
}
461491
```
462492

463493
</TabItem>

0 commit comments

Comments
 (0)