---
title: Allow traffic from specific countries only · Cloudflare Web Application Firewall (WAF) docs
description: This example blocks requests based on country code using the ip.src.country field, only allowing requests from two countries: United States and Mexico.
lastUpdated: 2025-01-17T12:22:49.000Z
source_url:
  html: https://patricia-pcx17119-l7-overrides.preview.developers.cloudflare.com/waf/custom-rules/use-cases/allow-traffic-from-specific-countries/index.md
  md: https://patricia-pcx17119-l7-overrides.preview.developers.cloudflare.com/waf/custom-rules/use-cases/allow-traffic-from-specific-countries/
---

This example blocks requests based on country code using the [`ip.src.country`](https://developers.cloudflare.com/ruleset-engine/rules-language/fields/reference/ip.src.country/) field, only allowing requests from two countries: United States and Mexico.

* **Expression**: `(not ip.src.country in {"US" "MX"})`
* **Action**: *Block*

## Other resources

* [Use case: Block traffic from specific countries](https://developers.cloudflare.com/waf/custom-rules/use-cases/block-traffic-from-specific-countries/)
