by LinuxBender · 3y ago · 0 comments
wc -l firehol_abusers*
7260 firehol_abusers_1d.netset
184010 firehol_abusers_30d.netset
# first grep for any IP's you care about and then:
for Ip in $(cat firehol_abusers_30d.netset);do ip route add blackhole "${Ip}" 2>/dev/null;done
If that cuts down on the noise then create a startup script to do this on reboot. The first time this should be done from a web console vs. ssh in case the list contains your own IP address or gateway. Why ip route vs ipset or iptables? Far less CPU load than netfilter.A more generic way to keep many bots out is to redirect anything other than HTTP/2.0 to a password protected listener. This will block Google bots as they still do not support HTTP/2.0 but will also block a majority of the problematic bots.
[1] - https://github.com/firehol/blocklist-ipsets/blob/master/fire...
Not for a blog. If this were a high performance computing node that needed extremely low latency CPU instruction performance then I would find another way but route enumeration at least in Linux and BSD are incredibly fast and efficient. I can't speak for other operating systems.
One method to test this would be to just start null routing more of those netsets not in a startup script and run load testing tools against the blog to see where it starts getting slower and to keep an eye on memory usage.
The bigger files to test with are:
2475418 firehol_proxies.netset
2480723 firehol_anonymous.netsetI also had to update that IP blacklist daily so that’s also why I chose redis.
Probably better ways to do it nowadays but that’s what I did like 8 years ago and it’s still one of my favorite solutions ever.
Also part of why nginx and redis will forever be two of my favorite technologies alongside Linux.