[Netfilter] Record IP address in F2B_ACTIVE_BANS instead of the network block #4759
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Minor change that can improve the whois output of watchdog's IP ban email in certain cases.
Currently watchdog receives the network block that was banned in the F2B_ACTIVE_BANS message. However a whois lookup of the block can fail to return a result if a larger/smaller block is what's actually registered. Example:
IP that caused the ban: 20.199.179.218
Fail2ban parameter f2b_netban_ipv4: 24
Resulting banned network: 20.199.179.0/24
Changing F2B_ACTIVE_BANS to contain the actual IP means watchdog can perform a successful query and include the output in its email:
Note that the IP is included in the the email subject so in this example it changes from:
Subject: Wed Sep 21 10:22:36 AEST 2022 - IP ban: 20.199.179.0/24
to:
Subject: Wed Sep 21 10:22:36 AEST 2022 - IP ban: 20.199.179.218
Personally I prefer that because it identifies the actual source of the attempt.
The other changes in the commit simply strip some superfluous whitespace. That was the result of an vim plugin that auto stripped the space. It wasn't an intended change but it cleans it up a bit I guess. :)