Locating and Blocking IP Addresses in WHM and via SSH

How to Locate and Block IP Addresses in WHM and via SSH

This article provides instructions on how to find and manage IP addresses that are making significant numbers of requests to your server using WHM and SSH, as well as how to block those IPs using the CSF (ConfigServer Security & Firewall) plugin in WHM or directly through the command line.

Finding IP Addresses

To locate IP addresses that are making the most connections to your server:

  1. Log into your WHM account using your root credentials.
  2. Search for 'Apache Status' in the search bar or navigate to 'Server Status' > 'Apache Status'.
  3. Examine the list of IP connections to see real-time access and resource utilization.

Note: 'Apache Status' provides a snapshot of active connections, allowing you to monitor traffic and understand which IPs are consuming server resources.

Blocking IP Addresses in WHM with CSF

To block IP addresses within WHM using the CSF plugin:

  1. Scroll down to the 'Plugins' section on the WHM home screen.
  2. Click on 'ConfigServer Security & Firewall'.
  3. In the 'csf - Quick Deny' section, enter the offending IP address and an optional comment for reference.
  4. Click 'Quick Deny' to block the IP address.

It’s important to provide a comment for documentation purposes, especially if multiple administrators access the firewall settings.

Blocking IP Addresses via SSH

You can also block IP addresses directly from the command line using SSH:

netstat -ntu | grep ESTABLISHED | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

This command sequence performs the following actions:

  • netstat -ntu: Lists all network connections using TCP and UDP protocols.
  • grep ESTABLISHED: Filters the list to show only established connections.
  • awk '{print $5}': Extracts the fifth field, typically the foreign address (IP:port).
  • cut -d: -f1: Removes the port number, leaving just the IP address.
  • sort | uniq -c | sort -n: Sorts the IP addresses and counts unique occurrences, ordering them numerically.

After identifying the IP addresses, use the following command to block them:

csf -d IP_ADDRESS "Reason for the block"

Replace IP_ADDRESS with the actual IP you intend to block, and include a reason for your records. Once done, apply the changes:

csf -r

If you have any further questions or require assistance with the process, feel free to contact support.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How do I access WHM?

To access your Web Host Manager you can simply open up internet explorer and navigate to:...

I can't create accounts using plan

In order to create accounts, first set up some packages of which your plans will be. Once these...

How do I login to WHM?

To log into your Webhost Manager and create/manage accounts, you must use one of the following...

How do I add a domain name?

To add a domain name to your reseller account simply follow the following directions: 1.) Login...

How do I create a new account in WHM?

To create a new account in WHM : Login to your WHM Control Panel and click the "Create New...