Comments (3)
Our issue template says clearly and explicitly what is needed for a filter request.
At least an excerpt with relevant log-lines is expected.
Thus closed, Please extend your request with needed info and I'll reopen it.
from fail2ban.
My apologies for not following the rules, at the time of writing my filter request I felt (incorrectly) that because every entry in the log file was to be banned; then the version, example log etc. was unnecessary. I will ensure I provide this information in the future.
from fail2ban.
Everything is important... Especially fail2ban version and log excerpt.
For instance if you don't have a timestamp in your monitored log, you'd need to set datepattern = {NONE}
and it'd work only for fail2ban >= v.0.11.2 (or v.0.10.6), where it was initially implemented. Without that the filter would not find any message, even with correct failregex
.
Here is an example for this log:
192.0.2.1 # evil
192.0.2.2 # also evil
[jail]
filter =
datepattern = {NONE}
failregex = ^<ADDR>
PoC:
$ fail2ban-regex '192.0.2.1 # evil' '^\s*<ADDR>'
... Lines: 1 lines, 0 ignored, 0 matched, 1 missed
$ fail2ban-regex -d '{NONE}' '192.0.2.1 # evil' '^\s*<ADDR>'
... Lines: 1 lines, 0 ignored, 1 matched, 0 missed
For log with timestamp the datepattern
(or default date-templates) need to match it firstly and failregex
must match a string without part cut out by datepattern
. For example:
2024-03-20 10:00:00 192.0.2.1 # evil
2024-03-20 10:01:00 192.0.2.2 # also evil
[jail]
filter =
datepattern = %%Y-%%m-%%d\s{0,2}%%H:%%M:%%S
failregex = ^\s*<ADDR>
whereby the datepattern
is optional here (just for illustration, as how-to), because this timestamp will be detected by fail2ban by default.
PoC:
$ fail2ban-regex -d '%Y-%m-%d\s{0,2}%H:%M:%S' '2024-03-20 10:00:00 192.0.2.1 # evil' '^\s*<ADDR>'
... Lines: 1 lines, 0 ignored, 1 matched, 0 missed
$ fail2ban-regex '2024-03-20 10:00:00 192.0.2.1 # evil' '^\s*<ADDR>'
... Lines: 1 lines, 0 ignored, 1 matched, 0 missed
By the way, <HOST>
will also match the IP-address, but also a hostname (or anything that looks like a hostname), so if only IP-address expected, <ADDR>
will be better choice.
If you rather want a subnet, see #2560
from fail2ban.
Related Issues (20)
- [FR]: nginx-limit-conn.conf HOT 1
- [BR]: wont run HOT 1
- [BR]: iptables action: no chains after start HOT 3
- [BR]: systemd-journal - Fail2Ban doesn't see all log records that journalctl does HOT 2
- unable to create multiple logs folders in logpath HOT 2
- [BR]: OOM (f2b/a.sshd invoked oom-killer) HOT 3
- Fail2ban unable to start in ubuntu 24.04 container HOT 2
- [RFE]: ASN/Country based ban using IPinfo's free IP to Country ASN MMDB database
- [BR]: ignoreregex are ignored if the line does not match "failregex" (making them more like "ignorematchingregex") HOT 1
- [FR]: coturn.log regex filter HOT 6
- [RFE]: Mix `<fid>` and `<ip>` in a ban action HOT 2
- [BR]: fail2ban complains about missing key in the default config file HOT 1
- [BR]: dpkg: warning: unable to delete old directory '/usr/lib/systemd/system': Directory not empty HOT 1
- [FR]: Fail2Ban stops functioning periodically without any evident reason HOT 1
- [BR]: ERROR: cannot import name 'MutableMapping' from 'collections' (/usr/lib/python3.11/collections/__init__.py) HOT 4
- [BR]: Jail works but no chain created in iptables HOT 4
- [BR]: STDIN is closed and triggers libuv error in external programs during actionban HOT 8
- [FR]: sshd failed login attempts not detected? HOT 1
- [RFE]: multi-line ignoreip doesn't handle end-of-line comments HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fail2ban.