How To Block WHM Server Access For Specific Countries?

The main benefit of blocking WHM server access for particular countries is to enhance the security of your server by reducing the risk of unauthorized access, brute force attacks, and other malicious activities originating from countries with a higher level of cybercrime.
Before we move forward to see how to block WHM server access for specific countries, ensure to enable the cPHulk function in your WHM panel, which is a built-in WHM function.

There are two ways to block WHM server access from specific countries.

  • Using the cPHulk built-in function provided by the WHM server
  • Using CSF Firewall

Block WHM Server Access With CPHulk Function

  1. Login to WHM Panel as the root user.
  2. Under the Security Center, select cPHulk Brute Force Protection.
    whm cphulk
  3. If the cPHulk function is disabled, click to enable it for your VPS.
    whm enable cphulk
  4. Once you enable this function, you will see multiple options and settings to protect your WHM server. Select Countries Management tab.
    whm cphulk country manage main
  5. Select the countries you want to block from the checkbox. Once you have selected all the countries you want to blacklist, click the gear icon on the right of the list. Select the option Blacklist Selected Countries from the options provided.
    whm cphulk country blacklist

Note: You can also search the country name in the search field at the top of the list and select Blacklisted from the radio button on the right side of the page.
whm cphulk country management
Once done, the selected countries are denied access to your Email, FTP, and cPanel.

Block Access Using CSF Firewall

We assume you have already installed CSF. Below are the steps to block traffic by country using the CSF firewall.

  1. Login to WHM Panel as the root user.
  2. Under the Plugins section, select ConfigServer Security & Firewall..
    whm plugin config firewall
  3. On the new page, click the Firewall Configuration option under csf-ConfigServer Firewall section.
    whm firewall configuration
  4. On the Firewall Configuration page, go to the Country Code Lists and Settings section. Here, you will find below two options: CC_DENY and CC_ALLOW. Input the two-alphabet country code in the CC_DENY field to block access from that country.
    whm firewall deny
  5. Note: You can add multiple countries separated by a comma with no intervening spaces. For example, US, GB, DE deny access to your desired countries.

  6. Click the Change button at the bottom of the page, shown in the image below.
    whm firewall change
  7. You will see a message saying your changes are saved. Now, you need to restart the firewall with the updated settings. Click on the Restart csf+lfd button as displayed on the following screenshot.
    whm firewall restart

That’s It! The countries are blocked.

Add a Comment

Your email address will not be published. Required fields are marked *