Block visitors by IP address

ip blocker, block, security, htaccess, bots, cidr · 0 found this helpful

Blocking an IP address stops that visitor from loading your site. Use it against a bot, a scraper, or someone abusing your contact form. Our firewall (Imunify360) already blocks many known bad addresses, so you only need this for specific cases.

Find the IP

Check your raw access logs or your visitor reports in Website statistics. The IP is the first item on each log line.

Block in your account

  1. Open Account → Hosting → your site → Security.
  2. Under Blocked addresses, type the address or range in IP address or range.
  3. Click Block.
Blocked addresses on the Security page

Accepted formats:

Format Example
Single IP 203.0.113.45
Range 203.0.113.1-203.0.113.50
CIDR 198.51.100.0/24
Wildcard 203.0.113.*

To unblock, click Unblock next to the entry in Blocked addresses.

Block with .htaccess

# Block a single IP and a CIDR range, allow everyone else
<RequireAll>
  Require all granted
  Require not ip 203.0.113.45
  Require not ip 198.51.100.0/24
</RequireAll>
# Allow only your office IP to reach wp-admin
<Files wp-login.php>
  Require ip 192.0.2.10
</Files>

The second rule locks you out if your home or office IP changes. Test it, and keep SFTP access to undo it.

Careful with ranges

Wide ranges can block real customers. Many mobile users share an address. Before blocking a range, look the address up to confirm it belongs to a hosting company or known abuse source.

If something goes wrong

  • You blocked yourself: sign in to your Barbrick account from another network, or contact support with your IP.
  • Block ignored: the visitor uses a different IP, or a CDN hides the real address. Check the CDN's firewall instead.
  • Attacks continue: ask support. See Harden WordPress security.

Was this helpful?

Still stuck? Ask us and we'll walk you through it.