Skip to content

Commit f0dc556

Browse files
committed
Added terraform and API code for the country geolocation block rule
1 parent 141c95a commit f0dc556

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

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

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,55 @@ resource "cloudflare_zero_trust_gateway_policy" "dns_restrict_quarantined_users"
146146

147147

148148
<Details header="All-DNS-GeoCountryIP-Blocklist">
149-
150149
Block websites hosted in countries categorized as high risk. The designation of such countries may result from your organization's users or through the implementation of regulations including [EAR](https://www.tradecompliance.pitt.edu/embargoed-and-sanctioned-countries), [OFAC](https://orpa.princeton.edu/export-controls/sanctioned-countries), and [ITAR](https://www.tradecompliance.pitt.edu/embargoed-and-sanctioned-countries).
151-
150+
<Tabs>
151+
<TabItem label="Dashboard">
152152
| Selector | Operator | Value | Action |
153153
| ------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
154154
| Resolved Country IP Geolocation | in | *Afghanistan*, *Belarus*, *Congo (Kinshasa)*, *Cuba*, *Iran*, *Iraq*, *Korea (North)*, *Myanmar*, *Russian Federation*, *Sudan*, *Syria*, *Ukraine*, *Zimbabwe* | Block |
155-
155+
</TabItem>
156+
<TabItem label="API">
157+
```sh
158+
curl --request POST \
159+
--URL https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/rules \
160+
--header 'Content-Type: application/json' \
161+
--header "Authorization: Bearer <API TOKEN>" \
162+
--data '{
163+
"name": "All-DNS-GeoCountryIP-Blocklist",
164+
"description": "Block traffic hosted in countries categorized as high security risks",
165+
"precedence": 50,
166+
"enabled": false,
167+
"action": "block",
168+
"filters": [
169+
"dns"
170+
],
171+
"traffic": "any(dns.dst.geo.country[*] in {\"AF\" \"BY\" \"CD\" \"CU\" \"IR\" \"IQ\" \"KP\" \"MM\" \"RU\" \"SD\" \"SY\" \"UA\" \"ZW\"})",
172+
"rule_settings": {
173+
"block_page_enabled": true,
174+
"block_reason": "This domain was blocked due to being classified as a security risk to the organisation"
175+
}
176+
}'
177+
```
178+
</TabItem>
179+
<TabItem label="Terraform">
180+
```tf
181+
resource "cloudflare_zero_trust_gateway_policy" "dns_geolocation_block_policy" {
182+
account_id = var.account_id
183+
name = "All-DNS-GeoCountryIP-Blocklist"
184+
description = "Block traffic hosted in countries categorized as high security risks"
185+
precedence = 50
186+
enabled = false
187+
action = "block"
188+
filters = ["dns"]
189+
traffic = "any(dns.dst.geo.country[*] in {\"AF\" \"BY\" \"CD\" \"CU\" \"IR\" \"IQ\" \"KP\" \"MM\" \"RU\" \"SD\" \"SY\" \"UA\" \"ZW\"})"
190+
rule_settings {
191+
block_page_enabled = true
192+
block_page_reason = "This domain was blocked due to being classified as a security risk to the organisation"
193+
}
194+
}
195+
```
196+
</TabItem>
197+
</Tabs>
156198

157199
</Details>
158200

0 commit comments

Comments
 (0)