IP Access Rules allow you to control access based on IP, ASN (Autonomous System Number), or country.
Add IPs of services that need unrestricted access to your site:
| Service | Action |
|---|---|
| Your office IP | Allow |
| CI/CD server | Allow |
| Payment Gateway (Stripe, etc) | Allow |
| Monitoring (UptimeRobot, etc) | Allow |
How to add:
# Stripe Webhooks - whitelist these IPs
3.18.12.63
3.130.192.231
13.235.14.237
13.235.122.149
18.211.135.69
35.154.171.200
52.15.183.38
54.88.130.119
54.88.130.237
54.187.174.169
54.187.205.235
54.187.216.72
When you identify an attacking IP in logs:
Tip: Use “Challenge” instead of “Block” if you’re not sure.
Some IP ranges are frequently used by attackers:
# Example - verify before blocking
# Data centers frequently used by bots
Caution: Blocking large ranges can affect legitimate users.
Option 1: Via IP Access Rules
Option 2: Via Custom Rules (recommended)
(ip.geoip.country in {"CN" "RU" "KP"})
Custom Rules are more flexible as they allow exceptions.
ASN is useful for blocking entire data centers used by bots:
# Example of ASNs frequently associated with bots
# Research before blocking
How to find ASN:
To manage many IPs, use IP Lists:
(ip.src in $blocked_ips_list)
Advantages:
Cloudflare evaluation order:
Important: IPs with “Allow” in IP Access Rules override country blocks, but do NOT override Custom Rules with Block.
# Allow only Brazil + Portugal + USA
not (ip.geoip.country in {"BR" "PT" "US"})
Action: Block
# Block everything except partners
not (ip.src in $partner_list)
Action: Block
# Staging only accessible from office
(http.host eq "staging.yoursite.com") and not (ip.src in {OFFICE_IP})
Action: Block
Ask the user to access: whatismyip.com
| Back to Cloudflare | View Snippets |