Geo blocking: refusing a country, and what the country really tells you
Geo blocking allows or refuses requests according to the country of the source address. The rule is simple to state and easy to overrate: the country is an estimate drawn from a database, and a request that looks foreign may come from a customer, while one that looks local may not. This page covers where the country comes from, where it fails, when a country rule is justified, and how to try one without refusing real people.
Quick facts
- What it does
- Allows or refuses a request by the country its source address maps to
- Where the country comes from
- A geolocation database, built from registry data and other sources; see RFC 7020
- Operator hints
- Networks can publish their own prefix-to-country lists, a format defined in RFC 8805
- Main risk
- Refusing real customers silently: VPN exits, mobile networks, stale records and travellers all produce wrong countries
A country rule is a business decision before it is a security one. It removes an audience, so decide whether that audience matters before deciding whether the rule works. It extends the address controls described in blocking IP addresses, and carries the same weakness: an address says where traffic comes from, not who sends it.
Where the country comes from
An IP address has no country in it. The number is allocated in blocks, and the allocation system is public: RFC 7020 describes it as IANA at the top, five regional internet registries below, and local registries, usually ISPs, below those. A registry record tells you which organisation holds a block. It does not say where each packet that leaves that block is physically produced.
Geolocation databases fill that gap. A vendor takes registry records and adds its own data to map each block to a place. MaxMind, for one, says in its accuracy notes that it estimates country-level identification at 99.8% accuracy and that it cannot guarantee 100%. The same notes say the data is never precise enough to locate a household or street address, and that accuracy varies by country, address type and the practices of the internet provider.
Operators can help. RFC 8805 defines a geofeed, a plain CSV file in which a network publishes its own prefixes with a country and, optionally, region and city. The RFC treats such data as a hint that a database may merge, not as an order, so a geofeed improves the data without making the result certain.
Two consequences follow. The answer depends on which database you use and how recently you updated it. And the unit being located is the network block, not the person.
Where the country is wrong
The errors are not rare corner cases; each is a normal way of using the internet.
VPNs and proxies
A VPN or proxy sends traffic from its exit server, so the request shows the exit's country. MaxMind states that for anonymising proxies it may locate the server running the VPN but cannot locate the end user, and that for consumer privacy networks the user may be anywhere in a region. A visitor who wants to reach a blocked country picks an exit elsewhere; a visitor who does not even know they are using one, such as an employee on a corporate VPN, gets refused by accident. A rented address in a permitted country passes the rule, which is why attackers are not stopped by it; the pattern is described in residential proxies.
Mobile networks
MaxMind notes that addresses on mobile networks may be used by phones across a large distance, and that in such cases it returns broader fields only. A country rule near a border, or on a carrier that routes traffic through a distant gateway, can therefore misplace a phone.
Stale and wrong records
Addresses change hands and move between networks. A database that is a few months old can place a block in last year's country. MaxMind advises customers to download updates as they are released; a rule that depends on a file nobody refreshes slowly turns into a list of mistakes. Reputation data ages the same way, as the page on IP reputation explains.
Shared and indirect addresses
If a proxy or CDN sits in front of your server, the address the server sees may be the proxy's. A country rule built on that address judges the proxy. The client address has to be taken from the right header, and only from a proxy you trust, as the notes on the web server setup describe.
People who move
Travellers, students abroad, expatriates, staff on a business trip and partners in the blocked country all appear as the country you refused. None of them reports it. A refused visitor rarely writes in; they leave, which is why false positives have to be looked for rather than waited for.
When a country rule is justified
Two reasons hold up.
A legal or licensing limit. You may be barred from serving a product, content or service in some places, by a licence, sanctions or a court order. A country rule is a reasonable, though imperfect, way to show good faith. Which obligations apply to you is a question for a lawyer, not for a configuration page, and the rule only reduces exposure rather than removing it, for the reasons above.
No audience there, and a lot of noise. If the business sells only in a few countries and the log shows steady unwanted traffic from elsewhere, refusing the rest cuts clutter. This is the weaker case, and it needs evidence from your own log, not a general belief that some countries are dangerous.
Two reasons do not hold up. One is stopping attacks: attackers choose addresses to fit your rules, and a country is a poor predictor of intent. The other is a vague wish to be safer. A rule with no stated purpose has no condition under which it can be removed, which is how old blocks end up refusing real customers years later.
Allowing instead of refusing is often cleaner. For a site with a known short list of markets, allow those countries and treat the rest as a smaller problem to review. For an admin panel or a partner endpoint, an address allowlist or a sign-in with a second factor beats any country rule.
What the refused visitor sees
The ordinary answer is 403 Forbidden, which RFC 9110 defines as the server understanding the request and refusing to fulfil it. That is accurate for most country blocks and says nothing about why.
When the cause is a legal demand, RFC 7725 defines 451 Unavailable For Legal Reasons. The RFC says a 451 response should include an explanation of the demand in its body and may carry a Link header with rel="blocked-by" that identifies the blocking party. It also warns that clients cannot rely on 451 being used, so do not treat its absence as proof that no legal block exists.
Whatever status you return, give the visitor a way to reach you. A refusal page with a contact address and a request for the time and address of the attempt turns a silent loss into something you can correct.
Starting in monitor mode
A country rule should begin as a measurement. The log tells you what the rule would do before it does it.
- Write the purpose and the expiry. "Licence excludes country X, review in six months" is a rule. "Seems risky" is not.
- Count by country first. Read the activity log and see which countries your requests, sign-ins and orders come from. Include the countries you expect to see only rarely.
- Run the rule in monitor. In monitor mode every request is still served and each match is recorded, so you can read the list of what would have been refused.
- Look for people you know. Check the matches against customers, partners, payment callbacks and your own staff. Anyone you recognise is a reason to narrow the rule.
- Move to block in steps. Apply it to part of the site first, following staged rollout, keep an exception path for the known address that gets caught, and look again after a week.
- Review on the expiry date. Update the database, re-read the log, and renew the rule or drop it.
Where a WAF helps and where it does not
A filter in front of a site sees the request: its source address, path, headers and body. It can attach a country to the address using a database. It cannot see the person, the device, or the place the request was typed. A country is therefore a coarse label on a connection, not evidence of a hostile act.
What helps: a record of which countries reach the site, a way to see what a rule would have refused, and a place to apply a limit once you are sure. What does not: telling a customer on a VPN from an attacker on the same VPN, or catching an attack that arrives from an allowed country. Request-level matching and limits per domain deal with behaviour, and behaviour does not depend on the flag.
On Bridge WAF specifically: it has no custom rules. It matches named categories and applies limits per domain, and address and country lists are kept in the server or network configuration in front of your site, as noted on the IP blocking page. Bridge WAF has three modes, off, monitor and block. Off inspects nothing, monitor records matches and serves every request, and block refuses matching requests and still records them. If you place a country list in front of the site, use the same discipline: watch first, refuse later.
If you suspect that your own address is the one being refused by someone else's rule, the IP blacklist check explains how to look. For ongoing tuning of what is refused, see Operations for the full set of pages.
Questions
What is geo blocking?
Geo blocking allows or refuses a request according to the country its source address maps to. The country comes from a location database, so the rule is only as good as that database and the address it is given.
Is geo blocking reliable?
Not as a security control. Location databases state that they are not exact, a VPN or proxy shows the country of its exit rather than the visitor, and mobile networks share addresses across wide areas. It suits legal and licensing limits better than it suits stopping attackers.
Which HTTP status code should a geo block return?
A plain refusal is usually 403 Forbidden. When access is denied because of a legal demand, RFC 7725 defines 451 Unavailable For Legal Reasons, though it also warns that clients cannot rely on it being used.
Does Bridge WAF have country rules?
Bridge WAF has no custom rules; it matches named categories and applies limits per domain. Address and country lists are kept in the server or network configuration in front of the site.
How should I start a country block?
Start by recording, not refusing: look at which countries your real customers and partners come from, run the rule in monitor mode, review what it would have refused, and only then switch to block, with an expiry date.