Skip to content

[Netfilter][Watchdog] Use source IP for ban notification WHOIS lookups - #7383

Open
gitterdoneplease wants to merge 1 commit into
mailcow:stagingfrom
gitterdoneplease:codex/fix-watchdog-whois-source-ip
Open

[Netfilter][Watchdog] Use source IP for ban notification WHOIS lookups#7383
gitterdoneplease wants to merge 1 commit into
mailcow:stagingfrom
gitterdoneplease:codex/fix-watchdog-whois-source-ip

Conversation

@gitterdoneplease

Copy link
Copy Markdown

Contribution Guidelines

What does this PR include?

Short Description

Fail2ban can expand the address that triggered a ban into a configured network range, such as /24. Watchdog currently passes that CIDR range to whois, which may not return useful registration data.

This change stores the triggering IP in a separate Redis hash keyed by the banned network. Watchdog uses that IP for its WHOIS lookup and falls back to the network address when no source mapping is available.

F2B_ACTIVE_BANS remains keyed by the banned network, preserving existing firewall, Web UI, and unban behavior.

This addresses #6843 and implements the separate-key approach discussed in #4759.

Affected Containers

  • netfilter-mailcow
  • watchdog-mailcow

Did you run tests?

What did you tested?

  • Parsed netfilter/main.py with Python's AST parser.
  • Validated watchdog.sh with bash -n.
  • Validated the Compose configuration with docker-compose config --quiet.
  • Checked whitespace and preserved the existing CRLF/no-final-newline format of netfilter/main.py.
  • Built local netfilter and watchdog images and deployed them on an active mailcow installation.
  • Tested a synthetic /24 ban mapping and then observed multiple naturally generated ban notifications.

What were the final results? (Awaited, got)

Expected:

  • Continue displaying and enforcing the configured banned network.
  • Query WHOIS using the individual IP that triggered the ban.
  • Include complete registration data in watchdog ban notifications.
  • Fall back safely when no source-IP mapping exists.

Got:

  • Firewall and Redis active-ban entries continued to use the configured network.
  • Watchdog notifications continued to identify the banned network.
  • Synthetic and naturally generated notifications returned complete WHOIS registration data instead of the CIDR-query error.
  • Python, Bash, Compose, and whitespace checks all passed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant