How to Blacklist an IP Address to Deny It Access to Your Website

Evans

Last Update 2 месяца назад

Blocking IP addresses can help protect your site from suspicious activity, spam, or brute-force attacks. Both cPanel and DirectAdmin provide options to block access based on IP addresses.

For cPanel Users

  1. Log in to your cPanel account

  2. Go to the Security section

    • Click on “IP Blocker.”

  3. Add the IP or IP Range

    • Under "Add an IP or Range", enter the IP address or range you want to block.

  4. Click on “Add”

    • cPanel will now deny access to that IP.

Example Formats:
  • Single IP Address: 192.168.0.1

  • Range: 192.168.0.1-192.168.0.40

  • Short Range: 192.168.0.1-40

  • CIDR Format: 192.168.0.1/32

Once added, any visitor from that IP or range will be blocked from accessing your website.

For DirectAdmin Users

DirectAdmin doesn't have a dedicated GUI tool like cPanel for IP blocking via browser, but you can achieve the same result by editing your .htaccess file or firewall configuration.


 Method 1: Using .htaccess (Recommended for shared hosting)

  1. Log in to DirectAdmin

  2. Go to File Manager

  3. Navigate to: File Manager > domains > yourdomain.com > public_html
  4. Edit the .htaccess file

    • If the file doesn’t exist, create a new one.

  5. Add the following lines:

Replace 192.168.0.1 and 203.0.113.0/24 with the IPs or ranges you want to block.




Method 2: Using CSF (for server admins with root access and CSF firewall installed)
  1. Log in to SSH as root

  2. Add IP to deny list:

3. Restart CSF if necessary:

That's it! The blocked visitors should now see a 403 Forbidden error or be denied access completely.

Was this article helpful?

0 out of 0 liked this article

Still need help? Message Us