How To Block VPN Users On Your Website: A Guide For Government Offices And Other Applications
Lily Roberts
Senior Marketing Strategist - ReVerb
11.14.2026
VPNs are everywhere now. Industry estimates put regular VPN use at roughly a quarter of all internet users, and that traffic hides where a visitor really is. For most websites that is fine. For a government portal, a bank, a betting site, an exam platform or a streaming service, it can be a real problem: fraud, sanctions exposure, licensing breaches and account takeovers all hide behind anonymized IPs.
This guide explains how websites detect VPN traffic, the practical ways to block or challenge it, and how to do it without locking out the legitimate citizens and customers you are there to serve.
Why Organizations Block VPN Traffic
Government services: Tax portals, benefits systems, identity and e-signature services, and voter or licensing systems often restrict access to domestic IPs to reduce credential stuffing, benefit fraud and foreign probing of public infrastructure. Russia’s Gosuslugi portal, for example, refuses sign-ins from foreign hosting and VPN IPs, and Chinese government sites geo-block most foreign access as a security measure.
Banking and fintech: Anonymized logins are a strong fraud signal. Banks commonly allow sessions only from expected locations and step up verification for everything else.
Streaming and media: Content licenses are sold by territory, so platforms must prove they enforce geo-restrictions.
Gambling, betting and regulated commerce: Operators are licensed per jurisdiction and can face penalties if players from unlicensed regions get in.
E-commerce and SaaS: VPNs enable regional price abuse, promo farming, multi-accounting and card testing.
Online exams and assessments: Proctoring and certification bodies need to confirm where candidates sit the test.
Communities and forums: Sites like Wikipedia restrict editing from VPNs and open proxies to stop ban evasion and vandalism.
How VPN Detection Works
No single signal proves a visitor is on a VPN. Reliable detection stacks several signals and scores the result.
1. IP intelligence and reputation
The most common method. Each incoming IP is checked against databases that classify addresses as commercial VPN, open proxy, Tor exit node, hosting/datacenter, relay (such as iCloud Private Relay) or residential. Commercial VPN servers mostly live in datacenters, so they are the easiest category to catch.
2. ASN and hosting provider checks
Every IP belongs to an Autonomous System Number (ASN). Traffic from cloud and hosting ASNs (AWS, DigitalOcean, OVH, M247 and similar) rarely comes from a real person browsing at home. Blocking or challenging hosting ASNs catches many VPNs, plus bots and scrapers, even when a specific VPN IP is not yet in any list.
3. Geolocation consistency checks
Compare what the IP claims against what the browser reveals: device timezone, browser language, and the location tied to the user’s account or previous logins. A visitor with an IP in Germany, a system clock set to UTC-6 and a Spanish-language browser deserves a closer look.
4. WebRTC and DNS leak checks
Some VPN setups leak the user’s real IP through WebRTC or send DNS queries to the local ISP’s resolver. A page script can surface the mismatch between the visible IP and the leaked one.
5. TLS and network fingerprinting
Fingerprints such as JA4 describe how a client negotiates its TLS connection. Combined with TCP/IP characteristics (MTU, TTL values, latency that does not match the claimed location), they help spot tunneled traffic. VPN providers cannot easily rotate around these signals the way they rotate IPs.
6. Behavioral and traffic patterns
Many unrelated accounts logging in from one IP, abnormal request volumes, or sessions that jump countries between clicks all point to shared anonymizer infrastructure. The BBC, for instance, blocks IPs that show an abnormal number of concurrent connections.
7. Deep packet inspection (network operators only)
Governments and enterprise networks can inspect traffic for VPN protocol signatures. This is a network-level tool for ISPs and corporate firewalls, not something a website can do to its visitors, and obfuscated protocols increasingly defeat it.
Ways to Block or Challenge VPN Users
Option 1: Use your CDN or WAF
If your site already sits behind a CDN or web application firewall, start here. No code changes are needed.
Cloudflare: Managed IP Lists include cf.vpn (known VPN servers), cf.anonymizer (VPNs, open proxies and Tor), cf.open_proxies, cf.malware and cf.botnetcc. Reference them in a custom WAF rule, for example (ip.src in $cf.vpn), with the action Block or Managed Challenge. Note that the full set of managed lists requires an Enterprise plan with the advanced tier; lower plans can still block hosting ASNs, Tor (via country code T1) and countries with custom rules.
AWS WAF: The Anonymous IP List managed rule group flags VPNs, proxies, Tor nodes and hosting providers and can be attached to CloudFront, API Gateway or an Application Load Balancer.
Other WAFs: Akamai, Fastly, Imperva and F5 offer comparable IP reputation or anonymizer categories. Check your plan for an “anonymous proxy” or “IP reputation” feature.
Option 2: Call a VPN and proxy detection API
For finer control, check the visitor’s IP at login, signup, checkout or form submission against a dedicated IP intelligence provider, then decide in your application logic. Established options include:
MaxMind (GeoIP Anonymous IP database and minFraud). Note that the free GeoLite2 database covers geolocation only and has no VPN flags.
IPinfo Privacy Detection API
IPQualityScore (IPQS) Proxy and VPN Detection API
Spur, strong on residential proxies and anonymization infrastructure
IP2Location and IP2Proxy databases
ipgeolocation.io, Abstract API and Greip, lighter-weight APIs with free tiers
Fingerprint, which adds device-level signals rather than relying on the IP alone
A typical flow looks like this:
Read the client IP (from the CDN header such as CF-Connecting-IP or X-Forwarded-For, never from untrusted headers directly).
Query the API or local database and cache the result for a few hours to control cost and latency.
Apply a policy: allow, step up verification, or block, based on the returned category and risk score.
Log the decision so you can review false positives.
Option 3: Server-level blocking
Without a CDN, you can block at the web server or firewall. Load a maintained list of VPN, Tor exit and hosting ranges (for example, the public Tor exit list, Spamhaus DROP, or a commercial feed) into nginx deny rules, an Apache Require not ip block, ipset with iptables/nftables, or a module such as nginx GeoIP2 paired with the MaxMind Anonymous IP database. This works but needs an automated update job, because VPN providers rotate IPs constantly and a static list goes stale within days.
Option 4: Geo-fencing to domestic IPs
Some government systems simply allow only IPs geolocated to their own country. It is blunt but effective against foreign VPN exits. On its own it does nothing against a domestic VPN server, so pair it with anonymizer detection.
Option 5: Application-level signals
Add client-side checks (timezone versus IP location, WebRTC leaks) and account-level checks (new country compared with login history) to your risk engine. These catch residential proxies and fresh VPN IPs that lists miss.
Block, Challenge or Allow: Choosing the Right Response
A hard block is rarely the best default. Match the response to the risk of the action being taken.
Account login or signupChallenge: CAPTCHA, MFA, or email/SMS verification.Payments, benefit claims, tax filing, changing bank detailsStep-up verification or block, with a clear message.Licensed content, betting, examsBlock anonymized traffic where licenses or regulations require it.Admin panels and internal toolsAllowlist only: your own corporate VPN or office IPs.Tor exit nodes and known abusive proxiesBlock on sensitive actions.
Situation
Recommended response
Reading public information pages
Allow.
Blocking VPNs here only hurts privacy-conscious citizens.
Special Considerations for Government Offices
Citizens abroad have a right to service. Expats, military personnel, diplomats and travelers often need tax, pension and identity services from outside the country. Offer an alternative route such as stronger identity verification, a consular channel or an exception process, rather than a dead end.
Your own staff may use VPNs. Remote employees connect through the agency’s VPN, which may itself look like datacenter traffic. Allowlist your own egress IPs before switching anything on.
Accessibility and fairness. Journalists, abuse survivors and other vulnerable users rely on VPNs for safety. Keep public information open and restrict only transactions.
Write the rule into policy. Document why anonymized traffic is restricted, which services are affected and how users can appeal. Publish a short notice so users know what to do.
Show a helpful error page. Explain that the connection appears to come from a VPN or proxy, ask the user to disconnect or use split tunneling for your domain, and list a contact option. Never return a blank page or generic 403.
Check legal requirements. Data protection rules may apply to the IP and device data you collect for detection, and some jurisdictions have accessibility duties for public services.
Common False Positives to Plan For
iCloud Private Relay and Cloudflare WARP: Millions of ordinary Apple and Cloudflare users appear as relay traffic. Most detection APIs flag these separately from commercial VPNs, so you can treat them more leniently.
Corporate VPNs: Employees of large companies often browse through their employer’s network.
Mobile carrier NAT: Many phone users share a small pool of IPs, which can look like abnormal traffic from one address.
Universities and libraries: Shared networks produce the same pattern.
Residential proxies: The reverse problem. These route traffic through real home connections and are the hardest category to detect from IP data alone, which is why layered signals matter.
Step-by-Step Rollout Plan
Define the goal. Fraud reduction, regulatory compliance or licensing? The goal decides how strict to be.
Map sensitive actions. List the pages and endpoints that actually need protection.
Pick your detection source. Your WAF’s built-in lists, a detection API, or both.
Run in log-only mode for two to four weeks. Measure how much traffic would be flagged and who it is.
Allowlist known good IPs. Staff VPNs, partners, monitoring services and search engine crawlers.
Turn on challenges first, then blocks. Start with verification on the riskiest actions.
Publish a clear block message and appeal route.
Review monthly. Check false positive reports and vendor accuracy. Test vendors against your own sample of known VPN IPs, because self-reported accuracy figures go stale quickly.
Limits of VPN Blocking
No method is complete. VPN providers rotate exit IPs, offer obfuscated protocols that look like ordinary HTTPS, and rent residential IPs that are hard to tell apart from real home users. A determined user will sometimes get through. The realistic aim is to raise the cost of abuse and to catch the bulk of anonymized traffic on high-risk actions, while keeping your service usable for everyone else. Treat VPN detection as one input into a broader risk decision, not a single on/off switch.
In most countries, yes. Website owners can generally decide who may access their services. Government bodies should check public service, accessibility and data protection obligations, and provide an alternative route for legitimate users.
Can I block VPNs for free?
Partly. You can block Tor exit nodes from the public exit list, block hosting provider ASNs with free WAF rules, and use free tiers of detection APIs for low volumes. Reliable coverage of commercial VPNs and residential proxies usually needs a paid feed.
Will blocking VPNs stop all fraud?
No. It removes an easy hiding place, but should sit alongside MFA, device fingerprinting, rate limiting and transaction monitoring.
Should I block iCloud Private Relay?
Usually not. It is used by ordinary iPhone and Mac owners and preserves the user’s rough region. Treat it as low risk unless your licensing terms require strict location proof.