This shell script is designed to manage banned IP addresses in Fail2Ban by monitoring the Fail2Ban log file and adding repeat offenders to a blacklist file (fail2many.txt
). It ensures that only unique IP addresses are added to the blacklist to prevent duplicates.
- Monitors the Fail2Ban log file for banned IP addresses.
- Maintains a blacklist file (
fail2many.txt
) containing banned IP addresses. - Ensures only unique IP addresses are added to the blacklist.
- Provides easy integration with Fail2Ban for enhanced IP management.
-
Place the script (
fail2many.sh
) in a convenient location on your system. -
Add a cron job to run the script regularly, e.g., once a day:
0 0 * * * /path/to/fail2many.sh > /dev/null 2>&1
-
Ensure the script has executable permissions (
chmod +x fail2many.sh
). -
Configure tcpwrappers to use the blacklist file (
fail2many.txt
) in thehosts.deny
configuration.
ALL : /etc/fail2many.txt
This project is licensed under the MIT License.
Contributions are welcome! Feel free to submit issues or pull requests to improve this script.