Skip to main content

Access Control — block or allow by IP, country (Geo) and ASN

Access Control decides whether to allow or deny a request before it reaches the other security layers, based on:

  • IP / CIDR (address range),
  • Geo (country, using 2-letter ISO codes such as VN, US),
  • ASN (network/provider, for example the ASN of a frequently abused hosting provider).

Use it when you only want to serve visitors from a few countries, need to block an attacking IP range or ASN, or want to whitelist your office IP range. Example: your service is only for visitors in Vietnam — set the default to deny and allow only VN.

Read carefully — allow opens everything. A matching allow rule (whether IP, Geo or ASN) lets the request go straight through, skipping the WAF, X-Vtoken and Token V2. So do not use allow for broad ranges (for example allow country = VN) if you still want the WAF to inspect visitors from VN. To "allow only VN" while keeping the WAF in the picture: set default action = deny + allow VN — but understand that visitors from VN are then fully trusted. If you need both geographic filtering and WAF inspection, consider using Firewall Rules (a geo condition + a block action for everything else) instead of allow here.

Before you start​

  • The domain has been added and points to VNIS.

How to configure​

  1. Go to Domains → select a domain → Access Control tab. Go to Domains → select a domain → Access Control tab
  2. Turn on Enabled. Choose the Default action (allow or deny) — this is what happens when no rule matches.
  3. Add rules in the appropriate group: IP rules / Geo rules / ASN rules. For each rule, choose allow or deny, set a priority, and optionally set match hostnames.
  4. Click Save (the first time, the button reads Create) and wait a few seconds for it to sync. The Remove button deletes the domain's entire Access Control configuration — including the Token V2 settings in the same tab.

Configuration fields​

FieldMeaningValuesDefaultNotes
EnabledTurns access control onOn/offOffOnly turns IP/Geo/ASN rules on or off. Token V2 (in the same tab) is independent of this switch — turning off Enabled does not turn off Token V2
Default actionWhat happens when no rule matchesallow / denyallowdeny = deny by default; only requests matching an allow rule get through
Geo rulesCountry rules≤50 rules—countries = uppercase 2-letter ISO codes (VN,US)
ASN rulesASN rules≤50 rules—asns = ASN numbers (for example 13335)
IP rulesIP/CIDR rules≤200 rules—Valid cidrs
(each rule) actionAllow/denyallow / denydenySee the allow warning at the top of this page
(each rule) priorityPriorityIntegerThe UI suggests one (highest existing priority + 10); empty in the API = 0Lower numbers win; on a tie, deny wins over allow
(each rule) match hostnamesWhich hostnames the rule applies to≤20, operators equals/contains/starts_with/ends_with/wildcard/regex—Empty = all hostnames of the domain

Limit on allow ranges: an allow rule with a CIDR broader than /8 (IPv4) or /16 (IPv6) is rejected when saved (400) — including 0.0.0.0/0, 0.0.0.0/1, ::ffff:0.0.0.0/96. This prevents accidentally opening everything. (The same rule applies to the whitelists of Token V2, X-Vtoken, Bot Management, Rate Limit and Firewall.)

Configuration examples​

Example 1 — Serve only visitors in Vietnam.

  • Default action: deny · Geo rule: allow countries = [VN], priority 10.
  • Result: visitors outside VN receive 403; visitors in VN get through (note: they are trusted and skip the WAF — see the top of this page).
  • Check: connect through a VPN abroad → 403; from VN → 200.

Example 2 — Block an attacking IP range.

  • IP rule: deny cidrs = [203.0.113.0/24], priority 5.
  • Result: every IP in that range receives 403.
  • Check: curl --resolve ... from an IP in the range (or look for block_reason=acl in the logs).

Example 3 — Block a frequently abused ASN (for example a hosting provider).

  • ASN rule: deny asns = [12345], priority 20.
  • Result: requests from networks in ASN 12345 receive 403; the log records block_reason=acl asn=12345.
  • Check: look in analytics/WAF logs for acl entries with that ASN.

Want to block by path (for example only /admin)? Access Control applies per domain/hostname, not per path. To "block visitors outside VN from /admin", use Firewall Rules with the condition ip.geoip.country ≠ VN AND http.request.uri.path starts_with /admin → action block. (See the Firewall Rules article.)

Order of evaluation​

  • First-match by priority: lower numbers win; on a tie, deny wins over allow. Scan order: IP → Geo → ASN.
  • Access Control runs very early (before X-Vtoken, Token V2, Rate limit and WAF). A matching allow rule skips all later layers (except those that already run before it).
  • If no rule matches, the Default action applies.

Troubleshooting​

SymptomCauseFix
Saving returns 400 when adding a broad allow rangeCIDR broader than /8 (v4) or /16 (v6)Narrow the range, or use deny for everything else instead of a broad allow
Visitors from VN are still blocked by the WAF even with allow VNallow VN actually skips the WAF — if requests are still blocked, another rule with a lower priority may be responsibleCheck the priority order; look for a deny rule with a lower priority
ASN rule has no effectMissing ASN data, or the client cannot be mapped to an ASNCheck the logs; make sure the request really comes from that ASN
You blocked yourselfdefault_action=deny without allowing the office IPAdd an allow IP rule for the office (remember the range limit)

FAQ​

  • Which takes precedence, allow or deny, when priorities are equal? deny wins.
  • Is country blocking 100% accurate? It is based on GeoIP and has a small margin of error; VPNs and proxies can get around it.
  • I want both geographic filtering and WAF inspection — how? Do not use allow country here (it skips the WAF). Use deny for unwanted countries, or use Firewall Rules.