Knowledgebase

How to block an IP address or a country from your website (cPanel IP Blocker)

Spam bots, people trying to guess your passwords or a scraper copying your content often come from the same IP addresses. This guide shows you how to block an IP address with the cPanel IP Blocker tool, how to block a whole range, and what your options are when you want to block a country.

What IP Blocker does (and does not do)

  • It stops the blocked addresses from opening your website. They get a 403 Forbidden page.
  • It works by adding deny rules to the .htaccess file in your account (see how to use the .htaccess file).
  • It does not block email, FTP or other services. It only affects web traffic.

How to block an IP address

  1. Log in to cPanel (how to log in to cPanel).
  2. In the Security section, open IP Blocker.
  3. In the IP Address or Domain box, type the address you want to block.
  4. Click Add. The address now appears under Currently-Blocked IP Addresses.

Formats you can use

FormatExampleBlocks
Single IP203.0.113.45One address
Range203.0.113.10-203.0.113.50Every address in the range
Short range203.0.113.10-50The same range, written shorter
CIDR203.0.113.0/24203.0.113.0 to 203.0.113.255
Partial203.0.113.Every address that starts with 203.0.113

IPv6 addresses are also accepted. If you type a domain name, cPanel looks up its IP address at that moment and blocks the IP, not the name.

Be careful: Do not block your own IP or a large range by mistake. Mobile networks and home internet in Egypt often share IP addresses between many customers, so a wide block can stop real visitors. Before you block, check your own IP by searching "what is my IP" in Google.

How to find the IP addresses to block

  • In cPanel, open Raw Access or Visitors (in the Metrics section) to see which IPs are requesting your pages.
  • In WordPress, a security plugin such as Wordfence or Limit Login Attempts shows the IPs of failed login attempts. See how to secure your WordPress website.

How to unblock an IP

  1. Open IP Blocker again.
  2. Under Currently-Blocked IP Addresses, click Delete next to the address and confirm.

How to block a country

IP Blocker works with IP addresses, not countries. A country has thousands of ranges that change over time, so pasting them into .htaccess by hand makes the file huge and slows the site. Better options:

  1. Cloudflare (recommended): if your domain uses Cloudflare, create a WAF custom rule with the field Country, choose the country and set the action to Block or Managed Challenge. This is available on the free plan and stops the traffic before it reaches your hosting.
  2. Ask EgWeb support: for persistent attacks, open a ticket. We can review the traffic and advise on blocking at server level.

Think carefully before you block a whole country. You may also block search engine crawlers, payment gateways or customers who travel.

Common problems

  • The blocked visitor can still open the site: they may be using a different IP, a VPN or Cloudflare. If your site is behind Cloudflare, block them in Cloudflare instead.
  • The whole site shows 403 after a change: you may have blocked a range that includes your own IP. Delete the entry from another network (for example mobile data).
  • Your own IP is blocked from cPanel or email: that is a server firewall block, not IP Blocker. Contact support with your IP address.

Frequently asked questions

Is there a limit to how many IPs I can block?

There is no fixed number, but a very long list in .htaccess slows every request. For large lists use Cloudflare.

Will blocking an IP stop a DDoS attack?

No. Large attacks come from thousands of addresses and must be filtered before they reach the server, for example by Cloudflare. Contact us if your site is under attack.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • ip blocker, block ip, block country, cpanel, security, cloudflare, htaccess

Was this answer helpful?

0 Users Found This Useful