Skip to content
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

[RFE]: Ability to Rescan Database File For New Bans #2982

Open
tldawson opened this issue Mar 23, 2021 · 1 comment
Open

[RFE]: Ability to Rescan Database File For New Bans #2982

tldawson opened this issue Mar 23, 2021 · 1 comment

Comments

@tldawson
Copy link

Feature request type

The ability to rescan the database for new bans in a clustered fail2ban setup.

Description

For clustered servers, it would be useful to store a central dbfile on an NFS and have each instance of fail2ban point to the NFS dbfile. It would be nice to be able to run a command like fail2ban-client reload dbfile in order to pull new bans from the central dbfile, or have it automatically check for new bans every so often.
Currently I have to restart the service in order to pull new bans from the dbfile onto each instance.

Considered alternatives

Another solution might be to support mysql as a backend since a lot of people are already using that in their application stack... but we'd still need some sort of ability to pull fresh bans from the db.

Any additional information

Also, I'm not sure if fail2ban can handle concurrent writes when two instances are trying to update the dbfile at the same time. Does anyone know if it does?

@sebres
Copy link
Contributor

sebres commented Mar 24, 2021

Currently I have to restart the service in order to pull new bans from the dbfile onto each instance.

Why?
fail2ban sql-database is available to read for multiple readers (depending on sqlite version, but if it is not too old)...
So you could do this:

sqlite3 'file:/var/lib/fail2ban/fail2ban.sqlite3?mode=ro' "$sql"

As well as backup it to another file, etc.

As regards rescan or (re)ban ability: see #2909 (in particular #2909 (comment) has a small example how you could do this, just read from some database and not from file).
Newest version also supporting notification about single attempts (protocol got extended to signal every particular failure).

As regards the clustering facility (e. g. fail2ban network), there is another RFE - #881 (may be you'd find some idea from there helpful also).

I'm not sure if fail2ban can handle concurrent writes ...
Does anyone know if it does?

Although WAL mode of sqlite3 permits simultaneous readers and writers, but I still don't see why you need it resp. what exactly you can do with database what you can not do with fail2ban client (communication protocol) or which advantages such in-place "upgrade" of database may provide (without to force fail2ban to reload it hereafter, what would be again very similar to restart).

Anyway fully fail2ban network support (active-active mode) is planed and I have an experimental branch doing it over ssh (still need to extract this to some public interface to be fully configurable and adjustable to support some other communication way).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants