在 DNS 过滤的上下文语境中,拦截列表 (Blocklist) 是已知有害域名或 IP 地址的列表。允许列表 (Allowlist) 是允许的域名或 IP 地址的列表,例如关键企业应用程序的域名。
Gateway 支持创建 URL、主机名或其他条目的列表,以便在你的策略中使用。
以下 DNS 策略将允许访问名为 Corporate Domains 的列表中包含的所有获批企业域名。
| 选择器 | 运算符 | 值 | 操作 |
|---|---|---|---|
| Domain(域名) | in list | Corporate Domains | Allow(允许) |
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "All-DNS-CorporateDomain-AllowList",
"description": "Allow access to the corporate domains defined under the Corporate Domains list",
"precedence": 1,
"enabled": true,
"action": "allow",
"filters": [
"dns"
],
"traffic": "any(dns.domains[*] in $<CORPORATE_DOMAINS_LIST_UUID>)"
}'使用 Terraform 创建新的 DNS 策略,以允许访问名为 Corporate Domains 的列表中包含的所有获批企业域名。
resource "cloudflare_zero_trust_gateway_policy" "allow_corporate_domain_access" {
account_id = var.cloudflare_account_id
name = "All-DNS-CorporateDomain-AllowList"
description = "Allow access to the corporate domains defined under the Corporate Domains list"
precedence = 1
enabled = false
action = "allow"
filters = ["dns"]
traffic = "any(dns.domains[*] in $<Corporate Domains List UUID>)"
}