How to Whitelist / Blacklist an IP ?

This guide explains how to manage IP addresses by adding them to the whitelist or blacklist in cPFence. Whitelisting allows specific IPs to bypass security rules, while blacklisting blocks access from specific IPs.

Add IP to Whitelist

To add an IP to the whitelist, use the following command:

cpfence --add-whitelist-ip IP

Replace IP with the IP address you want to whitelist, e.g., 192.168.1.1/23.

Remove IP from Whitelist

To remove an IP from the whitelist, use the following command:

cpfence --del-whitelist-ip IP

Replace IP with the IP address you want to remove, e.g., 192.168.1.1.

Add IP to Blacklist

To add an IP to the blacklist, use the following command:

cpfence --add-blacklist-ip IP

Replace IP with the IP address you want to blacklist, e.g., 192.168.1.1/24.

Remove IP from Blacklist

To remove an IP from the blacklist, use the following command:

cpfence --del-blacklist-ip IP

Replace IP with the IP address you want to remove, e.g., 192.168.1.1.

 

Bulk Importing IPs for Whitelisting or Blacklisting

cPFence now supports bulk importing IPs from files or URLs for whitelisting or blacklisting. This allows you to manage IP access across all your servers in one step.

Example Usage

To bulk whitelist IPs, use the following command:

cpfence --bulk-whitelist-ip https://a.com/custom_whitelist.txt

To automate this process with a cron job, you can add a crontab to keep all your servers synced with your custom rules:

Example Usage:

0 * * * * /usr/local/bin/cpfence --bulk-blacklist-ip https://a.com/custom_blacklist.txt

This feature supports both full paths and valid URLs.

Available Bulk Import Options :

  • cpfence --bulk-whitelist-ip URL_OR_FILE
    Bulk add IPs from a URL or file to the whitelist.
    (e.g., cpfence --bulk-whitelist-ip https://a.com/file.txt)

  • cpfence --bulk-blacklist-ip URL_OR_FILE
    Bulk add IPs from a URL or file to the blacklist.
    (e.g., cpfence --bulk-blacklist-ip /PATH/TO/FILE)

  • cpfence --bulk-del-wl-ip URL_OR_FILE
    Bulk delete IPs from a URL or file from the whitelist.
    (e.g., cpfence --bulk-del-wl-ip https://a.com/file.txt)

  • cpfence --bulk-del-bl-ip URL_OR_FILE
    Bulk delete IPs from a URL or file from the blacklist.
    (e.g., cpfence --bulk-del-bl-ip /PATH/TO/FILE)

--------

Use these commands to effectively manage IP access in cPFence, ensuring your network is secure and only authorized IPs can interact with your server.

 

  • bulk import ips, bulk whitelist, bulk blacklist
  • 0 användare blev hjälpta av detta svar
Hjälpte svaret dig?

Relaterade artiklar

How to use cPFence IPDB / DDoS Module ?

cPFence provides robust tools for managing IP databases (IPDB) and protecting against DDoS...

How to Whitelist / Blacklist a Full Country ?

This guide explains how to whitelist or blacklist entire countries in cPFence. You can manage...

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...