[CentOS] Blocking attacks from a range of IP addresses

Thu Jan 9 16:59:01 UTC 2020
Nataraj <incoming-centos at rjl.com>

On 1/9/20 2:08 AM, Pete Biggs wrote:
>> Has anyone created a fail2ban filter for this type of attack? As of
>> right now, I have manually banned a range of IP addresses but would
>> like to automate it for the future.
> As far as I can see fail2ban only deals with hosts and not networks - I
> suspect the issue is what is a "network": It may be obvious to you
> looking at the logs that these are all related, but you run the risk
> that getting denied accesses from, say, and and
> may be interpreted as a concerted attack and you banning half
> the internet - but that may not be a bad thing :-)
> What I've done in times of trouble is to be a bit more aggressive in
> why and how hosts are banned. It depends on how you are being attacked,
> but setting the threshold to 1 or 2 failures resulting in a ban and
> then setting the ban time to something fairly short. Repeat offenders
> will then quickly be picked up by the recidive filter and permanently
> banned.
> A downside to this is that your firewall filters get very large and
> things will inevitably slow down, but it will at least give you the
> chance to manually block a whole range but still give you a level of
> automated protection.
> P.
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos

Since you can configure fail2ban to invoke scripts, I would think it
would be possible to get it to block CIDRs (variable size subnets, i.e.  That said, I don't have a quick and easy implementation
on hand.

One thing that has proven useful to me in dealing with these kind of
attacks is to lookup the route for the specified IP address in the
Internet routing tables and then block the entire CIDR block.  You can
also determine which autonomous system (AS number) the attack is coming
from and block other routes owned by that provider.  Other options
include determining the GEOIP location, i.e. country of origin of the
attacks and block by country.

"whois" will also provide useful information about the CIDR
block that you are dealing with.

To look up routes on the Internet, connect to one of the route views
servers, such as this:

$ telnet route-server.ip.att.net

Follow login instructions provided in login banner, then give the command:

show route

and it will show you that this IP is part of the larger cidr block  So block instead of just one IP (assuming
your attacks are coming from a particular block.

You'll have to consider weather the cidr block that you are considering
blocking will impact your users or not.

The att route-server is a juniper.  Some route servers are Cisco's and
there you would use commands like:

show ip route


show ip bgp

An example of a cisco based route server would be to:

telnet route-views.routeviews.org

http://routeviews.org/ lists a bunch of route views servers down near
the bottom, which appear to be accessable by telnet.  Note, quagga based
route servers are open source immitations of the Cisco command interface
and have similar commands to the cisco's.