From 423188176f065f0a5f50972d9aa10d3e2b869e1b Mon Sep 17 00:00:00 2001 From: Casper Date: Wed, 3 May 2023 00:13:44 +0200 Subject: [PATCH] fail2ban: add 'log' command (#3299) Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> --- docs/content/config/security/fail2ban.md | 16 +++++++++++++++- target/bin/fail2ban | 10 +++++++++- target/bin/setup | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/content/config/security/fail2ban.md b/docs/content/config/security/fail2ban.md index 7a06fbf2..b9f8ad38 100644 --- a/docs/content/config/security/fail2ban.md +++ b/docs/content/config/security/fail2ban.md @@ -48,6 +48,16 @@ This following configuration files inside the `docker-data/dms/config/` volume w [github-file-f2bjail]: https://github.com/docker-mailserver/docker-mailserver/blob/master/config-examples/fail2ban-jail.cf [github-file-f2bconfig]: https://github.com/docker-mailserver/docker-mailserver/blob/master/config-examples/fail2ban-fail2ban.cf +### Viewing All Bans + +When just running + +```bash +setup fail2ban +``` + +the script will show all banned IP addresses. + ### Managing Bans You can manage F2B with the `setup` script. The usage looks like this: @@ -56,7 +66,11 @@ You can manage F2B with the `setup` script. The usage looks like this: docker exec setup fail2ban [ ] ``` -When just running `setup fail2ban`, the script will show all banned IP addresses. +### Viewing the Log File + +```bash +docker exec setup fail2ban log +``` ## Running Inside A Rootless Container diff --git a/target/bin/fail2ban b/target/bin/fail2ban index 8a01d1b6..f16fb87d 100755 --- a/target/bin/fail2ban +++ b/target/bin/fail2ban @@ -3,7 +3,11 @@ # shellcheck source=../scripts/helpers/index.sh source /usr/local/bin/helpers/index.sh -function __usage { echo "Usage: ./setup.sh fail2ban [ ]" ; } +function __usage +{ + echo "Usage: ./setup.sh fail2ban [ ]" + echo " ./setup.sh fail2ban log" +} fail2ban-client ping &>/dev/null || _exit_with_error "Fail2ban not running" @@ -73,6 +77,10 @@ else fi ;; + ( 'log' ) + cat /var/log/mail/fail2ban.log + ;; + ( * ) __usage _exit_with_error "Unknown command '${1}'" diff --git a/target/bin/setup b/target/bin/setup index daa4bf89..6496f74c 100755 --- a/target/bin/setup +++ b/target/bin/setup @@ -60,6 +60,7 @@ ${RED}[${ORANGE}SUB${RED}]${ORANGE}COMMANDS${RESET} setup fail2ban ${RESET} setup fail2ban ${CYAN}ban${RESET} setup fail2ban ${CYAN}unban${RESET} + setup fail2ban ${CYAN}log${RESET} ${LBLUE}COMMAND${RESET} debug ${RED}:=${RESET} setup debug ${CYAN}fetchmail${RESET}