跳转到内容
搜索文档

推荐的网络策略

最后更新 查看 MarkdownAgent 设置

我们建议你添加以下网络策略,为你的组织构建互联网和 SaaS 应用程序安全策略。

有关其他常用的网络策略示例,请参阅常用网络策略。有关构建网络策略的更多信息,请参阅网络策略

Quarantined-Users-NET-Restricted-Access(隔离用户:网络受限访问)

为包含在风险用户身份提供商(IdP)用户组中的用户限制访问。该策略可确保您的安全团队能够限制被检测到存在恶意或可疑活动的用户流量。

选择器 运算符 逻辑 操作
Destination IP(目标 IP) not in list(不在列表中) Quarantined-Users-IPAllowlist Or(或) Block(阻止)
SNI(服务器名称指示) not in list(不在列表中) Quarantined-Users-HostAllowlist Or(或)
SNI Domain(SNI 域名) not in list(不在列表中) Quarantined-Users-DomainAllowlist And(且)
User Group Names(用户组名称) in Quarantined Users
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Quarantined-Users-NET-Restricted-Access",
		"description": "限制 IdP 风险用户组中包含的用户的访问权限",
		"precedence": 0,
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "not(net.dst.ip in $<IP_ALLOWLIST_UUID>) or not(net.sni.host in $<HOST_ALLOWLIST_UUID>) or not(any(net.sni.domains[] in $<DOMAIN_ALLOWLIST_UUID>))",
		"identity": "any(identity.groups.name[] in {\"Quarantined Users\"})"
	}'
resource "cloudflare_zero_trust_gateway_policy" "quarantined_users_net_restricted_access" {
  account_id  = var.cloudflare_account_id
  name        = "Quarantined-Users-NET-Restricted-Access"
  description = "限制 IdP 风险用户组中包含的用户的访问权限"
  precedence  = 0
  enabled     = true
  action      = "block"
  filters     = ["l4"]
  traffic     = "not(net.dst.ip in ${"$"}${cloudflare_zero_trust_list.ip_allowlist.id}) or not(net.sni.host in ${"$"}${cloudflare_zero_trust_list.host_allowlist.id}) or not(any(net.sni.domains[*] in ${"$"}${cloudflare_zero_trust_list.domain_allowlist.id}))"
  identity    = "any(identity.groups.name[*] in {\"Quarantined Users\"})"
}

Posture-Fail-NET-Restricted-Access(姿态检查失败:网络受限访问)

限制对基线状态检查未通过的设备的访问。如果通过 API 将状态检查与 Crowdstrike 或 Intune 等服务提供商集成,此策略将动态阻断未满足预定安全要求的设备的访问。

为包含在风险用户身份提供商(IdP)用户组中的用户限制访问。该策略可确保您的安全团队能够限制被检测到存在恶意或可疑活动的用户流量。

选择器 运算符 逻辑 操作
Destination IP(目标 IP) not in list(不在列表中) Posture-Fail-IPAllowlist Or(或) Block(阻止)
SNI(服务器名称指示) not in list(不在列表中) Posture-Fail-HostAllowlist Or(或)
SNI Domain(SNI 域名) not in list(不在列表中) Posture-Fail-DomainAllowlist And(且)
Passed Device Posture Checks(已通过的设备姿态检查) not in Windows 10 or higher (OS version)
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "Posture-Fail-NET-Restricted-Access",
		"description": "限制基线设备状态检查未通过的设备的访问",
		"precedence": 10,
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "not(net.dst.ip in $<IP_ALLOWLIST_UUID>) or not(net.sni.host in $<HOST_ALLOWLIST_UUID>) or not(any(net.sni.domains[] in $<DOMAIN_ALLOWLIST_UUID>))",
		"device_posture": "not(any(device_posture.checks.passed[] in {\"<DEVICE_POSTURE_CHECK_UUID>\"}))"
	}'
resource "cloudflare_zero_trust_gateway_policy" "posture_fail_net_restricted_access" {
  account_id  = var.cloudflare_account_id
  name        = "Posture-Fail-NET-Restricted-Access"
  description = "限制基线设备状态检查未通过的设备的访问"
  precedence  = 10
  enabled     = true
  action      = "block"
  filters     = ["l4"]
  traffic     = "not(net.dst.ip in ${"$"}${cloudflare_zero_trust_list.ip_allowlist.id}) or not(net.sni.host in ${"$"}${cloudflare_zero_trust_list.host_allowlist.id}) or not(any(net.sni.domains[*] in ${"$"}${cloudflare_zero_trust_list.domain_allowlist.id}))"
  device_posture = "not(any(device_posture.checks.passed[*] in {\"${cloudflare_device_posture_rule.baseline_check.id}\"}))"
}

你可以根据需要添加多项 Cloudflare One Client 设备状态检查,例如磁盘加密 (Disk encryption)已加入域 (Domain joined)。有关设备状态检查的更多信息,请参阅强制执行设备姿态

FinanceUsers-NET-HTTPS-FinanceServers(示例)

允许用户组的 HTTPS 访问。例如,以下策略授予财务用户访问任何已知财务应用程序的权限:

选择器 运算符 逻辑 操作
Destination IP(目标 IP) in list(在列表中) Finance Servers And(且) Allow(允许)
User Group Names(用户组名称) in Finance Users
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "FinanceUsers-NET-HTTPS-FinanceServers",
		"description": "允许用户组的 HTTPS 访问",
		"precedence": 20,
		"enabled": true,
		"action": "allow",
		"filters": [
				"l4"
		],
		"traffic": "net.dst.ip in $<FINANCE_SERVERS_LIST_UUID>",
		"identity": "any(identity.groups.name[*] in {\"Finance Users\"})"
	}'
resource "cloudflare_zero_trust_gateway_policy" "finance_users_net_https_finance_servers" {
  account_id  = var.cloudflare_account_id
  name        = "FinanceUsers-NET-HTTPS-FinanceServers"
  description = "允许用户组的 HTTPS 访问"
  precedence  = 20
  enabled     = true
  action      = "allow"
  filters     = ["l4"]
  traffic     = "net.dst.ip in ${"$"}${cloudflare_zero_trust_list.finance_servers_list.id}"
  identity    = "any(identity.groups.name[*] in {\"Finance Users\"})"
}

All-NET-Internet-Blocklist(全部网络:互联网阻止列表)

阻断发送到属于恶意或对你的组织构成威胁的目的地 IP、SNI 和 SNI 域名的流量。

您可以通过创建自定义阻止列表,或使用威胁情报合作伙伴或区域计算机应急响应小组(CERT)提供的阻止列表来实现此策略。理想情况下,您的 CERT 可以通过 API 自动化来更新阻止列表,以提供实时威胁防护。

选择器 运算符 逻辑 操作
Destination IP(目标 IP) in list(在列表中) IP Blocklist Or(或) Block(阻止)
SNI(服务器名称指示) in list(在列表中) Host Blocklist Or(或)
SNI Domain(SNI 域名) in list(在列表中) Domain Blocklist
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "All-NET-Internet-Blocklist",
		"description": "阻断发送到恶意或有风险的目的地 IP、SNI 和 SNI 域名的流量",
		"precedence": 30,
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "net.dst.ip in $<IP_BLOCKLIST_UUID> and net.sni.host in $<HOST_BLOCKLIST_UUID> and any(net.sni.domains[*] in $<DOMAIN_BLOCKLIST_UUID>)"
	}'
resource "cloudflare_zero_trust_gateway_policy" "all_net_internet_blocklist" {
  account_id  = var.cloudflare_account_id
  name        = "All-NET-Internet-Blocklist"
  description = "阻断发送到恶意或有风险的目的地 IP、SNI 和 SNI 域名的流量"
  precedence  = 30
  enabled     = true
  action      = "block"
  filters     = ["l4"]
  traffic     = "net.dst.ip in ${"$"}${cloudflare_zero_trust_list.ip_blocklist.id} and net.sni.host in ${"$"}${cloudflare_zero_trust_list.host_blocklist.id} and any(net.sni.domains[*] in ${"$"}${cloudflare_zero_trust_list.domain_blocklist.id})"
}

All-NET-SSH-Internet-Allowlist(全部网络:SSH 互联网允许列表)

允许特定用户发送到互联网上特定端点的 SSH 流量。你可以为需要访问的其他非 Web 端点创建类似的策略。

(可选)你可以包含一个选择器以按源 IP 或 IdP 组过滤。

选择器 运算符 逻辑 操作
Destination IP(目标 IP) in list(在列表中) SSHAllowList Or(或) Allow(允许)
SNI(服务器名称指示) in list(在列表中) SSHAllowlistFQDN And(且)
Detected Protocol(检测到的协议) is SSH And(且)
User Group Names(用户组名称) in SSH-Allowed-Users
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "All-NET-SSH-Internet-Allowlist",
		"description": "允许特定用户发送到互联网上特定端点的 SSH 流量",
		"precedence": 40,
		"enabled": true,
		"action": "allow",
		"filters": [
				"l4"
		],
		"traffic": "net.dst.ip in $<SSH_IP_ALLOWLIST_UUID> and net.sni.host in $<SSH_FQDN_ALLOWLIST_UUID> and net.detected_protocol == \"ssh\"",
		"identity": "any(identity.groups.name[*] in {\"SSH-Allowed-Users\"})"
	}'
resource "cloudflare_zero_trust_gateway_policy" "all_net_ssh_internet_allowlist" {
  account_id  = var.cloudflare_account_id
  name        = "All-NET-SSH-Internet-Allowlist"
  description = "允许特定用户发送到互联网上特定端点的 SSH 流量"
  precedence  = 40
  enabled     = true
  action      = "allow"
  filters     = ["l4"]
  traffic     = "net.dst.ip in ${"$"}${cloudflare_zero_trust_list.ssh_ip_allowlist.id} and net.sni.host in ${"$"}${cloudflare_zero_trust_list.ssh_fqdn_allowlist.id} and net.detected_protocol == \"ssh\""
  identity    = "any(identity.groups.name[*] in {\"SSH-Allowed-Users\"})"
}

All-NET-NO-HTTP-HTTPS-Internet-Deny(全部网络:非 HTTP/HTTPS 互联网拒绝)

阻断发送到互联网的所有 non-web 流量。通过使用 Detected Protocol(检测到的协议) 选择器,你将确保允许 HTTP 和 HTTPS 的备用端口。

选择器 运算符 逻辑 操作
Destination IP(目标 IP) not in list(不在列表中) InternalNetwork And(且) Block(阻止)
Detected Protocol(检测到的协议) not in HTTP, HTTP2
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "All-NET-NO-HTTP-HTTPS-Internet-Deny",
		"description": "阻断发送到互联网的所有非 Web 流量",
		"precedence": 50,
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "not(net.dst.ip in $<INTERNAL_NETWORK_IP_LIST_UUID>) and not(net.detected_protocol in {\"http\" \"http2\"})"
	}'
resource "cloudflare_zero_trust_gateway_policy" "all_net_no_http_https_internet_deny" {
  account_id  = var.cloudflare_account_id
  name        = "All-NET-NO-HTTP-HTTPS-Internet-Deny"
  description = "阻断发送到互联网的所有非 Web 流量"
  precedence  = 50
  enabled     = true
  action      = "block"
  filters     = ["l4"]
  traffic     = "not(net.dst.ip in ${"$"}${cloudflare_zero_trust_list.internal_network_ip_list.id}) and not(net.detected_protocol in {\"http\" \"http2\"})"
}

All-NET-InternalNetwork-ImplicitDeny(全部网络:内部网络隐式拒绝)

隐式拒绝列表中包含的所有内部 IP 范围。我们建议你将此策略放置在策略列表的底部,以确保你显式批准上述策略中定义的流量。

选择器 运算符 操作
Destination IP(目标 IP) in list(在列表中) Internal Network IPs Block(阻止)
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "All-NET-InternalNetwork-ImplicitDeny",
		"description": "隐式拒绝列表中包含的所有内部 IP 范围",
		"precedence": 60,
		"enabled": true,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "net.dst.ip in $<INTERNAL_NETWORK_IP_LIST_UUID>"
	}'
resource "cloudflare_zero_trust_gateway_policy" "all_net_internalnetwork_implicitdeny" {
  account_id  = var.cloudflare_account_id
  name        = "All-NET-InternalNetwork-ImplicitDeny"
  description = "隐式拒绝列表中包含的所有内部 IP 范围"
  precedence  = 60
  enabled     = true
  action      = "block"
  filters     = ["l4"]
  traffic     = "net.dst.ip in ${"$"}${cloudflare_zero_trust_list.internal_network_ip_list.id}"
}

All-NET-ApplicationAccess-Allow(全部网络:应用程序访问允许)

仅允许来自已知且获批设备的网络流量。

在以下示例中,您可以使用 设备序列号 列表,以确保用户只有在从公司设备使用 Cloudflare One 客户端连接时才能访问应用程序:

选择器 运算符 逻辑 操作
SNI 域名 (SNI Domain) is internalapp.com 且 (And) 阻止 (Block)
通过设备状态检测 (Passed Device Posture Checks) not in 设备序列号 (Device serial numbers)
Create a Zero Trust Gateway rulebash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"name": "All-NET-ApplicationAccess-Allow",
		"description": "Ensure access to the application comes from authorized WARP clients",
		"precedence": 70,
		"enabled": false,
		"action": "block",
		"filters": [
				"l4"
		],
		"traffic": "any(net.sni.domains[*] == \"internalapp.com\")",
		"device_posture": "not(any(device_posture.checks.passed[*] in {\"<DEVICE_SERIAL_NUMBERS_LIST_UUID>\"}))"
	}'

要获取设备状态检测的 UUID,请使用 列出设备状态规则 端点。

resource "cloudflare_zero_trust_gateway_policy" "all_net_applicationaccess_allow" {
  account_id  = var.cloudflare_account_id
  name        = "All-NET-ApplicationAccess-Allow"
  description = "Ensure access to the application comes from authorized WARP clients"
  precedence  = 70
  enabled     = false
  action      = "block"
  filters     = ["l4"]
  traffic     = "any(net.sni.domains[*] == \"internalapp.com\")"
  posture			=	"not(any(device_posture.checks.passed[*] in {\"${"$"}${cloudflare_zero_trust_list.allowed_devices_sn_list.id}\"}))"
}

这篇文档对您有帮助吗?