Blocking traffic by country is one of the easiest controls to switch on and one of the easiest to overrate. Geo-IP blocking cuts noise from automated scanning and credential attacks and can shrink the exposure of services that only a known population uses, but it rests on location data that is inferred, not measured, and any attacker with a local VPN, cloud server or compromised home router steps around it. This guide gives network and security operations teams a balanced view: where country blocking helps, how it fails, how accurate geolocation data is at country, region and city level, why sanctions compliance is a separate obligation, and how to design, test and monitor a policy. It complements the Firewall Management Guide, which covers rule lifecycle in general.
Key takeaways
- It is a noise filter, not a perimeter. Country blocking reduces opportunistic traffic; it does not stop a targeted attacker, who can source traffic from inside any allowed country.
- Location is inferred from registry data, operator feeds and measurement. Country-level results are usually right but not always, and region or city results are much less reliable, so never build city-level rules for security.
- Block where you never do business, and allow by exception. The safest designs block inbound access to user-facing and admin services from countries with no legitimate users, with named, time-limited exceptions for travel.
- Sanctions compliance is a different job. Regulators expect IP geolocation as one input to a sanctions programme alongside customer identification and transaction screening; a firewall geo-rule alone does not meet that duty.
- Measure what it blocks and what it breaks. Track blocked volume, false blocks reported by users, exception counts and the share of attacks that arrive from allowed countries anyway.
What geo-IP blocking does
A geo-IP rule looks up the source (or destination) IP address in a geolocation database, gets an ISO 3166-1 alpha-2 country code, and allows, blocks or challenges the connection based on that code. It appears in several places, each with different effects:
| Enforcement point | Typical use | What it sees | Main caveat |
|---|---|---|---|
| Edge firewall or next-generation firewall | Inbound VPN, SSH, RDP gateways, mail and web servers; outbound to unwanted regions | Packet source IP | Coarse; affects every service behind the rule |
| Web application firewall or CDN | Public websites and APIs, rate limiting by country | Client IP at the edge, plus headers | Rule must use the edge-observed IP, not a spoofable header |
| Identity provider conditional access | Sign-in policies by country (block, require MFA, require compliant device) | Sign-in IP, sometimes device GPS | Proxies and cloud egress change the evaluated IP |
| Application logic | Licensing, content rights, sanctions screening at onboarding | Client IP and account data | Needs a compliance owner and audit trail |
| DNS resolver or secure web gateway | Outbound blocking of destinations hosted in chosen countries | Destination IP after resolution | CDN-hosted sites resolve to many countries |
Microsoft's Entra documentation is a useful illustration of the mechanics: the service resolves the sign-in IPv4 or IPv6 address to a country or region using a periodically updated mapping table, admits that some addresses cannot be mapped at all (hence an option to include "unknown countries/regions"), and evaluates the proxy's address, not the client behind it, when traffic comes through a cloud proxy or VPN. It also describes a country block as restrictive and to be used with care after thorough testing. In MITRE D3FEND terms, an edge geo-rule is a form of Inbound Traffic Filtering (D3-ITF) or Outbound Traffic Filtering (D3-OTF), and using location in sign-in analytics is User Geolocation Logon Pattern Analysis (D3-UGLPA).
Where it helps
- Admin and remote access surfaces: VPN portals, SSH bastions and RDP gateways used only by staff in a few countries. Blocking everywhere else removes most password spraying and credential stuffing volume (ATT&CK T1110 Brute Force against T1133 External Remote Services) and makes the remaining attempts easier to review.
- Region-bound applications: a council portal, a domestic payroll service or an internal SaaS tenant with no foreign users.
- DDoS and bot pressure: during an attack, temporarily blocking or challenging countries that supply most of the traffic and none of the customers buys time while upstream mitigation catches up.
- Identity risk signals: country as an input to conditional access (require phishing-resistant MFA or a compliant device from new countries) rather than a hard block. See Impossible Travel and Anomalous Sign-In Detection.
- Outbound controls: servers that should only talk to a short list of partners or update hosts gain little from geography, but workstations in high-assurance zones can use outbound country rules as an extra layer against command-and-control in unexpected places.
- Machine identities: service principals, CI runners and API keys normally connect from known cloud regions or office egress points. A location condition on workload sign-ins, or an allowlist of egress IPs, limits where a stolen token or key can be used. See Conditional Access for Workload Identities.
Limits and bypasses (VPNs, cloud, proxies)
| Where geo-blocking helps | Where it fails |
|---|---|
| Cuts opportunistic scanning and spraying from countries with no users | Attackers rent a VPS or VPN exit in an allowed country in minutes |
| Shrinks log volume so analysts see the remaining attempts | Residential proxy networks and compromised home routers present local, residential IPs |
| Quick, reversible lever during DDoS | Large botnets are spread across allowed countries too |
| Adds a signal to conditional access | Cloud and CDN address space moves between regions; mobile carrier gateways can place users far from where they are |
| Enforces "we never operate there" decisions cheaply | Legitimate travellers, remote staff and partners get blocked, which drives risky workarounds |
The bypass is not theoretical. CISA's joint advisory on Volt Typhoon (AA24-038A) describes the actors using multi-hop proxies built from virtual private servers and end-of-life small office and home office routers infected with KV Botnet malware (ATT&CK T1090.003 Multi-hop Proxy, T1584 Compromise Infrastructure). Infrastructure like that can sit in any country, including your own, so a country rule does nothing against it. What the same advisory recommends instead is reviewing logons for impossible travel and not exposing management interfaces to the internet at all, which is a stronger control than any geo-rule.
Other common bypass and breakage paths:
- Trusting headers: rules that read
X-Forwarded-Forfrom untrusted clients can be bypassed by setting the header. Only trust it when set by your own proxy or CDN. - IPv6 gaps: rules written only for IPv4, or databases with sparser IPv6 data, leave a parallel path open or mislabel it.
- Unknown country: addresses with no mapping fall through to the default action. Decide explicitly whether "unknown" is blocked or allowed.
- Encrypted DNS and CDNs outbound: destination country rules break when popular services resolve to edge nodes in many countries.
Geolocation data accuracy
No registry publishes "where an IP address is". Location databases combine regional internet registry (RIR) allocation records, operator-supplied data, routing and latency measurements, and user-contributed signals. The RIPE NCC states plainly that it is not a geolocation provider and does not verify the optional location attribute holders can add to registry objects. Two IETF documents improve operator input:
- RFC 8805 (Informational, August 2020): a CSV format,
ip_prefix,alpha2code,region,city,postal_code, that network operators self-publish to say how their prefixes should be located. It is best effort: consumers may treat feeds as a hint, should check the publisher is authoritative for the address space, and should refresh at least weekly. The format deliberately supports only coarse location and deprecates postal codes. - RFC 9632 (Standards Track, August 2024, obsoletes RFC 9092): lets registry
inetnum:objects point to a geofeed file with ageofeed:attribute, and defines an optional signature using an RPKI certificate so consumers can check the feed is authorised for those addresses.
Independent measurement shows why caution is needed. A study presented at the ACM Internet Measurement Conference 2017 (Gharaibeh and colleagues, "A Look at Router Geolocation in Public and Commercial Databases") compared four databases against ground truth for router addresses and found country-level accuracy of roughly 77.5% to 89.4% depending on the database, with city-level accuracy lower still (about 73% for the best database). Router addresses are harder than end-user addresses and the data is from 2017, so treat these figures as a reminder of error rates, not as current accuracy for any product.
| Granularity | Reliability for security rules | Typical error sources | Use it for |
|---|---|---|---|
| Continent | High | Anycast and global cloud ranges | Very coarse traffic shaping |
| Country | Usually right, with a real error rate | Recently reassigned blocks, multinational ISPs, VPN and cloud egress, mobile gateways | Block or challenge lists, with exceptions and an "unknown" decision |
| Region or state | Low to moderate | ISPs route customers through central gateways; sparse operator feeds | Analytics and risk scoring only |
| City or postal code | Low | Inferred from nearest infrastructure; deliberately coarse feeds | Never for blocking; investigation context at most |
Two practical consequences follow. First, update the database on the vendor's schedule and record which version a rule evaluated against, because a disputed block is impossible to explain otherwise. Second, give users and partners a route to report a wrong location, and check whether their provider publishes a geofeed before adding a manual override.
Business, legal and sanctions considerations
- Sanctions are a separate obligation: OFAC's Sanctions Compliance Guidance for the Virtual Currency Industry tells firms to incorporate geolocation tools and IP address blocking controls, and to screen against known VPN addresses, but presents them as one part of a risk-based programme alongside customer identification and transaction screening. The UK, EU and other jurisdictions run their own regimes. Owners of sanctions compliance, usually legal or financial crime teams, decide what must be blocked and what evidence must be kept; network teams implement and log. See the CDD, EDD, PEP and sanctions screening guide.
- Do not let a security block stand in for compliance: a firewall rule with no owner, no review record and no screening of account data will not show a regulator that the programme works, and removing it during troubleshooting can create a breach of sanctions without anyone noticing.
- Customer and accessibility impact: blocking whole countries can cut off customers abroad, expatriate staff, journalists and humanitarian users. Record the business owner's acceptance.
- Privacy: location derived from IP is personal data in many jurisdictions when linked to an account. Keep geolocation in logs for a defined retention period and purpose.
- Contracts and service levels: partners and managed service providers may connect from countries not on your list; agree egress IPs in the contract instead of granting a country exception.
Designing and monitoring a policy
Decision guidance
| Situation | Approach |
|---|---|
| Small organisation, staff in one country, no foreign customers | Allowlist home country (plus "unknown" decision) on VPN and admin portals; challenge rather than block on the identity provider |
| Large or multinational organisation | Denylist countries with no users or business; country as a risk signal in conditional access; no blanket allowlists |
| Public website or API | Challenge or rate limit by country at the WAF during attacks; avoid permanent blocks unless legal or licensing requires them |
| Workload identities and partners | Allowlist specific egress IP ranges, not countries |
| Sanctions-driven blocking | Owned by compliance, enforced at onboarding and transaction points as well as the network edge, with an audit trail |
Rollout steps
- Inventory exposure: list internet-facing services and who legitimately uses them, by country, from 30 to 90 days of logs.
- Decide per service: block, challenge or log only, and how unknown-country traffic is treated. Get the business owner's sign-off.
- Run in log-only or report-only mode for two to four weeks and review what would have been blocked, especially VPN, partner and mobile traffic.
- Set up exceptions: a travel request process that grants a named user a time-limited exception (for example, sign-in allowed from the destination country with phishing-resistant MFA for the travel dates). See the Travel Cybersecurity Guide.
- Enforce in rings: admin portals first, then remote access, then broader services; keep a documented one-step rollback (switch the rule back to log only).
- Review quarterly: recertify the country list, exceptions and the database update status with the firewall rule review.
What to log and measure
- Log fields: source IP, resolved country, database version, rule ID, action, and the user or workload identity where known.
- Blocked volume by service: confirms the rule is doing work; a sudden drop can mean a broken rule or database.
- False blocks: helpdesk tickets tagged as location blocks per month; rising numbers point to bad data or an outdated list.
- Exception count and age: number of active exceptions and how many are past their end date.
- Attacks from allowed countries: share of confirmed malicious sign-ins or scans that came from allowed countries; a high share shows where other controls must carry the load.
- Unknown-country rate: share of traffic with no mapping, to check the default action is sensible.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev. 5 | SC-7 Boundary Protection, AC-17 Remote Access, SI-4 System Monitoring | Edge filtering, restricting remote access, monitoring blocked and allowed traffic |
| NIST CSF 2.0 | PR.IR-01, DE.CM-01 | Protecting networks from unauthorised access; monitoring networks |
| MITRE D3FEND | D3-ITF, D3-OTF, D3-UGLPA, D3-IPRA | Inbound and outbound filtering; geolocation logon analysis; IP reputation as a complementary signal |
| MITRE ATT&CK | T1110, T1133, T1090.003, T1584 | Attacks it reduces, and proxy infrastructure that bypasses it |
For a complementary signal that does not depend on location, see D3-IPRA IP Reputation Analysis.
Practitioner checklist
- List each internet-facing service, its legitimate user countries and its business owner before writing any rule.
- Apply country rules first to VPN, bastion and admin portals, and remove direct internet exposure of management interfaces where possible.
- Decide and document the action for unknown-country and IPv6 traffic.
- Run every new rule in log-only or report-only mode before enforcing, and keep a one-step rollback.
- Operate a time-limited travel exception process tied to named users and stronger MFA.
- Use egress IP allowlists, not countries, for workload identities, partners and managed service providers.
- Keep sanctions blocking under a compliance owner with screening beyond IP and an audit trail.
- Log the database version with each decision and update it on schedule.
- Review the country list, exceptions and the five metrics quarterly.
Standards and references
- IETF: RFC 8805, A Format for Self-Published IP Geolocation Feeds
- IETF: RFC 9632, Finding and Using Geofeed Data
- US Treasury OFAC: Sanctions Compliance Guidance for the Virtual Currency Industry
- CISA: PRC State-Sponsored Actors Compromise and Maintain Persistent Access to U.S. Critical Infrastructure (AA24-038A)
- RIPE NCC: Geolocation in the RIPE Database
- Microsoft Learn: Network assignment in Conditional Access policy
- APNIC Blog: Should we trust the geolocation databases to geolocate routers?
Related NHI Mgmt Group resources: Firewall Management Guide · Web Application Firewall Guide · Travel Cybersecurity Guide · D3-UGLPA User Geolocation Logon Pattern Analysis