27
loading...
This website collects cookies to deliver better user experience
apt-get
and run instal fail2ban as a root user. Theses are Debian/Ubuntu commands for CentOS yum
would replace apt-get
and paths/locations might differ for configuration files. Check this tutorial for non-Debian operating systems.sudo apt-get update
sudo apt-get install fail2ban
[Definition]
# Option: loglevel
# Notes.: Set the log level output.
# CRITICAL
# ERROR
# WARNING
# NOTICE
# INFO
# DEBUG
# Values: [ LEVEL ] Default: ERROR
#
loglevel = INFO
logtarget = /var/log/fail2ban.log
# Options: dbfile
# Notes.: Set the file for the fail2ban persistent data to be stored.
# A value of ":memory:" means database is only stored in memory
# and data is lost when fail2ban is stopped.
# A value of "None" disables the database.
# Values: [ None :memory: FILE ] Default: /var/lib/fail2ban/fail2ban.sqlite3
dbfile = /var/lib/fail2ban/fail2ban.sqlite3
# Options: dbpurgeage
# Notes.: Sets age at which bans should be purged from the database
# Values: [ SECONDS ] Default: 86400 (24hours)
dbpurgeage = 86400
[apache-auth]
enabled = true
port = http,https
logpath = /var/log/apache2/error.log
maxretry = 3
findtime = 600
bantime = 1h
[apache-noscript]
port = http,https
logpath = %(apache_error_log)s
ignoreip = localhost or an IP
[apache-overflows]
logpath = %(apache_error_log)s
maxretry = 2
[apache-nohome]
port = http,https
[apache-botsearch]
enabled = true
port = http,https
maxretry = 2
[apache-badbots]
port = http,https
logpath = %(apache_access_log)s
[php-url-fopen]
port = http,https
[roundcube-auth]
port = http,https
logpath = %(roundcube_errors_log)s
#if roundcube logs to journal then use following.
#backend = %(syslog_backend)s
[openwebmail]
port = http,https
logpath = /var/log/openwebmail.log
[horde]
port = http,https
logpath = /var/log/horde/horde.log
sudo fail2ban-client status
sudo fail2ban-client status apache
sudo fail2ban-client set apache banip x.x.x.x
sudo fail2ban-client set apache unbanip x.x.x.x
sudo systemctl restart fail2ban
sudo iptables -L
sudo systemctl enable fail2ban