Adding IP Ranges to Fraudguard Blacklists and Whitelists
At Fraudguard.io, we’re committed to providing comprehensive tools to help you manage IP blacklists and whitelists effectively. Currently, our system does not support CIDR notation or IP ranges directly, but there’s an easy workaround to add individual IP addresses from a CIDR range to your blacklists or whitelists. This post provides a quick script to do just that!
The Challenge: CIDR and IP Range Support
If you’re working with CIDR notation or need to block or allow an IP range, you might have noticed that Fraudguard’s API doesn’t yet support directly adding IP ranges. Instead, each IP must be added individually, which can be tedious when dealing with larger subnets.
The Solution: Bash Script for IP Ranges
Below is a simple Bash script that takes a CIDR range, expands it into individual IP addresses, and then adds each IP to your Fraudguard blacklist (or whitelist) one by one.
Requirements:
Make sure you have prips installed on your system. This utility expands a CIDR range into a list of individual IP addresses.
Here’s the code you can use:
#!/bin/bash
CIDR="12.1.6.0/24" # Replace with your desired CIDR range
for ip in $(prips $CIDR); do
echo "IP: $ip"
curl -X POST -u "username:password" -d '["'$ip'"]' "https://api.fraudguard.io/blacklist"
sleep 1 # Adds a slight delay to avoid rate limiting issues
done
Why Use This Script?
Using this script provides flexibility for those who need to manage IP lists at a granular level. Whether you’re dealing with repeated attacks from a specific subnet or need to allow access to multiple IPs within a range, this script streamlines the process until native support for CIDR and ranges is added to Fraudguard.
Conclusion
While Fraudguard.io’s API doesn’t yet support CIDR notation or IP ranges, simple scripting can provide a powerful workaround for efficiently managing blacklists and whitelists. As always, we’re working on enhancing our features and welcome any feedback.