How to Whitelist / Blacklist a Full Country ?

Note: Please use the Blacklist/Whitelist Countries feature judiciously. Limiting this setting to 2 or 3 countries is recommended, as applying it to a large number of countries may negatively impact system performance.

This guide explains how to whitelist or blacklist entire countries in cPFence. You can manage these settings either through the browser-based WebUI, the command line, or by editing the configuration file (useful for bulk changes).

Tip: You can find the correct ISO codes at ISO 3166-1 alpha-2.

Part 1: Using the cPFence WebUI

 

 

Open the cPFence WebUI on your Main Control Panel server.

  1. Go to Tools & Utilities in the left sidebar.
  2. Under the Country Blacklisting / Whitelisting section, choose one of the following options:
    • Whitelist Country
    • Blacklist Country
    • Remove Whitelisted Country
    • Remove Blacklisted Country
  3. Enter the ISO-2 country code and click the button (e.g., Whitelist or Blacklist).

The screenshots above are samples—use the same steps for all country management actions (whitelist, blacklist, remove from whitelist, remove from blacklist).


Part 2: From CLI 

Whitelist a Country

To add a country to the whitelist, use the following command:

cpfence --whitelist-country ISOCODE

Replace ISOCODE with the two-letter ISO code (e.g., us for United States).

Blacklist a Country

To add a country to the blacklist, use:

cpfence --blacklist-country ISOCODE

Replace ISOCODE with the country code (e.g., cn for China).

Remove Country from Whitelist

cpfence --del-whitelist-country ISOCODE

Replace ISOCODE with the ISO code (e.g., us).

Remove Country from Blacklist

cpfence --del-blacklist-country ISOCODE

Replace ISOCODE with the ISO code (e.g., cn).


Part 3: From Configuration File

For bulk deployment across several servers, you can edit the configuration file directly. Edit, copy it to your servers, then run cpfence --restart to apply changes.

Blocked Countries

Add ISO codes below this line:

# BLOCKED COUNTRIES : (DO NOT DELETE THIS LINE! - Your blocked countries should go below this line) 
BLOCKED_COUNTRY=cn 
BLOCKED_COUNTRY=ru 

Whitelisted Countries

Add ISO codes below this line:

# WHITELISTED COUNTRIES : (DO NOT DELETE THIS LINE! - Your whitelisted countries should go below this line) 
WHITELISTED_COUNTRY=us 
WHITELISTED_COUNTRY=fr 

Applying Changes

Restart cPFence to load your new settings:

cpfence --restart

Important Notes

  • Only use the configuration file editing method for new servers or when you’re OK with resetting IP settings.
  • Whitelisted countries bypass all IPDB/DDoS protections—use with caution.

Need Further Assistance? If you encounter any issues or need additional help, feel free to reach out to our support team via your client portal.

  • 18 用戶發現這個有用
這篇文章有幫助嗎?

相關文章

How to Fix Bulk IP Blacklisting or Whitelisting Issues in cPFence?

If you're facing issues when attempting to bulk blacklist or whitelist IPs in cPFence, the most...

How to Automate Blocking with Online IP Blacklists in cPFence?

cPFence provides a robust IP Database (IPDB) that dynamically adapts to new threats by updating...

Why cPFence May Not Block Certain Connections?

cPFence is designed to intelligently handle incoming traffic and block malicious or abusive...

Am I Under a DDoS Attack? I See Hundreds of GET Requests in the Logs

Read Also: How to Address High Server Load Issues with cPFence? If you're noticing hundreds of...

Why Does a Whitelisted IP Still Appear in cPFence Stats?

If you’ve whitelisted an IP in cPFence but it still appears in the statistics, there’s no need to...