Bulk adding IPs to the grey-/black- and whitelist

You are here:
Estimated reading time: 1 min

If you use a service that requires you to whitelist multiple IP addresses or you have multiple IP addresses that are blocked currently in your current firewall or in any other way and you wish to transition them to the BitNinja ipsets.

Bulk actions can be done via the BitNinja CLI. You can also add IP addresses to the blacklist and the whitelist from the Dashboard.

Bulk Whitelist and Blacklist from the Dashboard

The Add many feature is not yet available for the greylist. It is only available for the Blacklist and whitelist at the moment.

For this feature open the Firewall menu and click on the Blacklist or Whitelist menu and click on the “ADD MANY” button.

And add the IP addresses separated by enter. Each IP address or IP address range should be in a new line.
You can also set an expiration date for the IP address after that it gets delisted from the blacklist or whitelist.

You can also select the server where you would like to whitelist/ blacklist the IP addresses on. If there is no server selected the IP addresses will be added on all server’s whitelist or blacklist. The servers cannot be specified afterwards per IP address.

Bulk greylisting, blacklisting, and whitelisting from the BitNinjaCLI

Example of a script that adds a list of IP addresses to your whitelist blacklist or greylist:

  1. Create a file called iplist.txt and insert the Ip addresses you would like to check/add
    e.g.: nano iplist.txt and paste the IP addresses and then press ctrl+ x then y then enter
  2. Make a file called AddToGreylist.sh and paste the text below into it
    e.g.: nano AddToGreylist.sh

while read line; do echo $line;

        #bitninjacli --greylist/ --blacklist/ --whitelist --add/ --del/ --check = IPaddress

        bitninjacli --greylist --add=$line
        #bitninjacli --blacklist --add=$line
        #bitninjacli --whitelist --add=$line

done < $1
  1. Issue the command chmod +x AddToGreylist.sh so it will be executable
  2. Run the command and pass the iplist.txt file as a parameter to it with ./AddToGreylist.sh iplist.txt
The maximum limit for manual greylisting is 2000 to avoid flooding.
Views: 1269