IP Blocking vs. Geo-Blocking — When to Use Each and How to Set Them Up

Picture of Edward Samuel
Edward Samuel

Lead Architect @ Enigmaking

Table of Contents

Not all traffic to your website is welcome. Bots probing login pages, scrapers hoovering your content, repeat attackers hammering your server — these are real and common. Two of the most practical tools for handling unwanted traffic are IP blocking and Geo-blocking. They are often mentioned in the same breath, but they solve different problems. Using the wrong one for a given situation wastes effort and can block legitimate users.

This article explains both approaches clearly, outlines when each one is appropriate, and shows how to implement them on a WordPress site.

What Is IP Blocking?

IP blocking prevents access from a specific IP address or a defined range of IP addresses. When a request comes from a blocked IP, the server refuses the connection and the visitor sees an error or nothing at all.

IP blocking is precise. It targets a specific source, not an entire region or country. This makes it the right tool when you can identify a particular bad actor.

When to Use IP Blocking

After a brute force attack. If your security logs show repeated failed login attempts from a specific IP address, blocking that IP stops the attack at the source. Most security plugins can do this automatically based on failed login thresholds.

After a bot swarm from identifiable IPs. Enigmaking’s own infrastructure survived a 10,000-bot attack, and part of the response involved identifying and blocking the IP ranges being used in the attack. Not every IP in a bot network is unique, and blocking the most active sources reduces load significantly even if it does not eliminate the attack entirely.

Blocking known malicious IP ranges. Threat intelligence databases maintain lists of IPs associated with known malicious activity. Some security plugins pull from these databases automatically and block the IPs in their lists.

Repeat offenders after investigation. If a specific IP has triggered security rules multiple times over a period of days or weeks, manual blocking is appropriate.

When IP Blocking Is Not the Right Tool

IP blocking is ineffective against distributed attacks where each request comes from a different IP. A botnet with thousands of unique addresses will not be stopped by blocking individual IPs. In that scenario, you need a different approach: rate limiting, a Web Application Firewall (WAF), or geo-blocking if the traffic has a geographic pattern.

IP addresses are also not permanent. Dynamic IP assignment means that the address used by a malicious actor today might be assigned to a legitimate user tomorrow. Aggressive IP blocking on shared IP ranges can catch innocent parties.

What Is Geo-Blocking?

Geo-blocking, sometimes called country blocking or geolocation filtering, prevents access based on the country or region associated with a visitor’s IP address. Instead of blocking a specific address, you block all traffic from a geographic location.

Geo-blocking is a blunt instrument. It is effective when an entire region is irrelevant to your audience and consistently represents a disproportionate share of bad traffic.

When to Use Geo-Blocking

Your site serves a local or regional audience exclusively. If a client is a Port Harcourt restaurant, there is no legitimate reason for traffic from Eastern Europe or East Asia. Blocking regions that consistently produce bot traffic and have no plausible legitimate audience makes sense.

Attack traffic has a clear geographic pattern. If your logs show that 90% of malicious traffic originates from a specific country, geo-blocking that country removes most of the attack surface without requiring individual IP management.

Compliance or legal requirements. Some businesses are restricted from serving users in certain jurisdictions. Geo-blocking can be part of the compliance architecture in these cases.

Reducing server load from irrelevant traffic. Bot traffic consumes server resources even when it does not succeed in causing harm. Blocking regions that send exclusively automated traffic with no business value reduces unnecessary load.

When Geo-Blocking Is Not the Right Tool

When your audience is global. An international e-commerce store, a SaaS platform, or a publication with a worldwide readership cannot afford to block entire countries. A legitimate customer in a blocked region becomes a lost sale.

When you want to block a specific bad actor, not a region. If you have identified a specific problematic IP, use IP blocking. Geo-blocking is disproportionate in that case.

As a substitute for other security measures. Geo-blocking reduces surface area, but it does not secure your site. VPNs and proxies allow determined attackers to bypass geo-blocks trivially. Treat it as one layer among several, not a primary defence.

How to Set Up IP Blocking in WordPress

Using Wordfence

Wordfence (free and premium) is one of the most capable WordPress security plugins and includes both manual and automatic IP blocking.

Automatic blocking: Under Wordfence > Firewall > Brute Force Protection, configure the number of failed login attempts and the lockout duration. Wordfence will automatically block IPs that exceed the threshold.

Manual blocking: Under Wordfence > Blocking, you can add specific IP addresses, IP ranges using CIDR notation, or even block based on browser user agent strings.

Real-time threat intelligence (premium): Wordfence Premium includes the Real-Time IP Blocklist, which automatically blocks IPs flagged as malicious by Wordfence’s network-wide threat data.

Using .htaccess (Apache servers)

For direct server-level blocking without relying on a plugin:

# Block a specific IP

<RequireAll>

Require all granted

Require not ip 123.456.789.0

</RequireAll>

# Block an IP range (CIDR notation)

<RequireAll>

Require all granted

Require not ip 123.456.789.0/24

</RequireAll>

This approach is efficient because it blocks at the server level before WordPress even loads.

Dev Note: Editing .htaccess directly carries risk. A syntax error can take your site offline. Before making changes, download a backup copy of the file first. If you are not comfortable with this, use Wordfence’s blocking interface instead — it achieves a similar result through a WordPress admin panel with no file editing required.

Using Cloudflare

If your site is behind Cloudflare, IP blocking can be managed at the network edge before traffic ever reaches your server. Under Security > WAF > Tools, add IP rules to block specific addresses or ranges. This is the most efficient approach because blocked traffic never consumes your server resources.

How to Set Up Geo-Blocking in WordPress

Using Wordfence Premium

Geo-blocking is a premium feature in Wordfence. Under Wordfence > Blocking, select “Country Blocking” and choose the countries you want to block. You can also configure whether to block the REST API and XML-RPC endpoints from those countries specifically.

Using Cloudflare (Free and Pro Plans)

Cloudflare’s free plan includes basic geo-blocking under Security > WAF > Tools. Select “Block” as the action and “Country” as the field, then specify the country. For more complex rules such as blocking a country except for specific URLs, Cloudflare’s Firewall Rules allow that level of granularity.

Cloudflare’s geo-blocking operates at the edge, which is the most performance-efficient implementation available.

Using IP2Location or MaxMind with Custom Code

For developers who want fine-grained control without a third-party service dependency, integrating a geolocation database such as IP2Location or MaxMind GeoLite2 directly into WordPress is possible. This approach requires more setup but gives full control over the logic.

 

Dev Note: This is a developer task. It involves downloading a database file, writing custom PHP, and keeping the database updated regularly. For most site owners, Wordfence Premium or Cloudflare’s geo-blocking covers this need without any custom code.

Using a WordPress Plugin: IP Geo Block

IP Geo Block is a dedicated WordPress plugin for both IP and geo-based blocking. It uses multiple geolocation databases and offers country-level blocking, whitelist functionality, and detailed logging. Useful for sites that want geo-blocking without committing to a full security plugin suite.

Combining Both Approaches

IP blocking and geo-blocking are not mutually exclusive. A well-configured security setup might:

  • Block specific malicious IPs identified through attack logs
  • Block countries with no legitimate audience that produce consistent bot traffic
  • Use a WAF (Wordfence or Cloudflare) to catch threats that slip past both
  • Whitelist known legitimate IPs such as the site administrator’s office IP to prevent accidental lockout

The key is not to over-block. Every legitimate visitor you block is a visitor you lose. Start with what you can justify: identifiable bad actors and irrelevant regions. Expand only based on observed traffic patterns.

What to Check Before You Block

Before implementing geo-blocking at scale, check your analytics for the past 90 days:

  • Which countries are your legitimate visitors coming from?
  • Which countries represent the highest proportion of bot or spam traffic in your logs?
  • Do any of the high-traffic-abuse countries also have legitimate business connections?

Make decisions based on data, not assumptions. Blocking a country blindly because it has a reputation for abuse, when your analytics show real customers there, is a mistake you will hear about.

IP blocking and geo-blocking are practical, effective tools when used correctly. IP blocking is surgical, right for known bad actors and specific threats. Geo-blocking is broad, right for reducing exposure from regions with no legitimate audience. Used together as part of a layered security posture, they reduce attack surface meaningfully without requiring constant manual intervention.

Stay updated with practical insights on performance and security Digital Experiences

No spam — just clear, actionable insights.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted

Need a site that looks sharp and holds up in production?