-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Whole IP pool block #1154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can accomplish this by creating iptables-multiport-24.conf file in the /etc/fail2ban/action.d/ directory.
Then add the following below.
Now modify the jail(s) that you want to have the subnet blocked ...
Add the action = iptables-multiport-24 line to the jail...
Also check out #1161 |
@agentmoller001 The suggested What I did : |
I came here to ask something like this, or to find out if it can be done. I manually go through the fail2ban emails and block the CIDR range for each IP that gets a lot of attacks over different IPs - but this is quite work intensive so I rarely do it. What would be good if fail2ban was aware that say multiple different IPs from the same AS/range block in X days/weeks/months results in a complete range ban. Having it for a repeat attacking single IP would be sort of useful, but then just block that single IP and might do false positives - I am wary about blocking UK/US etc for that reason. It is the crafty people who come back from the same block of Iran or Chinese IPs months later and blast my server that need to be entire range autoblocked. Indeed I know geoblocking is beyond f2b but that would be good, I do it easily for nginx but that does not cover other services, mail, etc. |
Hi @sebres Sorry newbie at fail2ban @ github. My system is FreeBSD with PF PS: Length of IPv4 and IPv6 netmask different. |
@agentmoller001 for fixed subnet, do you have equivalent settings for firewalld and nftables? I second that this should be a feature. I currently have about 700 IPs from a single /20 AS in my block list. That's quite a few /24's. |
I just updated /etc/fail2ban/action.d/iptables.conf to have actionBan and actionUnBan just always use /24 instead of |
@edwardsd97 -- could you share what tweak you made, specifically? For example, for actionban, what in
did you change? Did you simply add /24 after ? In other words..
Thanks in advance. Rather ask a 'silly question' than blow up iptables. |
when looking for official/registered IP blocks to ban, I personally think it's probably best to use a remote source of truth since blocks are purchased and assigned by an authority. Assuming their information is up to date, will give you varying levels of officially registered IP blocks, however, I am not familiar with how to enter these values into the field in actionban. Also, I am utilizing the default action on Fedora, which is firewalld, and utilizing nftables on debian, so is a little dated and less useful to me. From what I'm reading, it seems like most people are still stuck on iptables :) |
Yep that’s all I did. I only need to access my server from a couple
specific machines so have no problem over banning potentially
…On Fri, Feb 2, 2024 at 12:23 PM Evan Cooch ***@***.***> wrote:
@edwardsd97 <https://github.com/edwardsd97> -- could you share what tweak
you made, specifically? For example, for actionban, what in
actionban = <iptables> -I f2b-<name> 1 -s <ip> -j <blocktype>
did you change? Did you simply add /24 after ? In other words..
actionban = <iptables> -I f2b-<name> 1 -s <ip>/24 -j <blocktype>
Thanks in advance. Rather ask a 'silly question' than blow up iptables.
—
Reply to this email directly, view it on GitHub
<#1154 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABPAMO2BNEYRYXYZBGY3CK3YRUVILAVCNFSM4BNDIGMKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJSGQ2DIOBYGMZQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Perfect - thanks. I had convinced myself that was correct, after trying some experiments with AlmaLinux in a VM, but confirmation from your end helps. As seems to be the case at your end, my main machine(s) are only intended for a couple of users, so I'm quite comfortable blocking way more than fail2ban defaults to. Thanks again. |
It was a topic here before but with a wrong approach ( IMHO ) #953
The idea is simple, if an ISP continuously scanning / doing nasty stuff then the full ISP pool should get blocked, and most likely permanently, right now I do that manually, and parsing the fail2ban log to returning AS numbers, and above a limit I drop them on the permanent block firewall set.
In this way the 134176, 23650,4134 made it to the list on the first week, but it would be nice to automate it.
I use the cymru whois service now for lookup if you know any better feel free to share.
When there is more then x ( in my case 3 ) block from the same AS then the action to put the BGP Prefix to the list.
Now this function need few things like AS lookup function with up to date database, but it does not looks impossible for me, but also this would mean that one threat of the fail2ban would monitor it's own log which could be funny.
Maybe it's easier to push it into database ( sqlite3 or something simple, or even shared p2p ), anyway let me know guys, what you think, let's open the conversation about this again.
The text was updated successfully, but these errors were encountered: