File 2 Ban
File 2 Ban
File 2 Ban
com/how-to-configure-firewall-and-fail2ban-for-prevent-brute-force-attack-
zimbra-8.6-on-ubuntu-server-14.04-lts-step-by-step/
How to configure firewall and fail2ban for prevent brute force attack Zimbra 8.6 on Ubuntu
(Server) 14.04 LTS Step-by-Step
Fail2ban is an intrusion prevention framework written in the Python programming language. It is able to run
on POSIX systems that have an interface to a packet-control system or firewall installed locally for example,
iptables or TCP Wrapper. Fail2ban operates by monitoring log files for selected entries and running scripts
based on them. Most commonly this is used to block selected IP addresses that may belong to hosts that are
trying to breach the systems security. It can ban any host IP that makes too many login attempts or performs
any other unwanted action within a time frame defined by the administrator. Ill be logged in as root.
Step 5 Reload the ban Ip Address after restart. In the /etc/fail2ban/action.d/iptables-allports.conf file you
must remove everything from this file and copy and paste this script.
[Definition]
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
actionstart = iptables -N fail2ban-
iptables -A fail2ban- -j RETURN
iptables -I INPUT -p -j fail2ban-
if [ -f /etc/fail2ban/ip.blacklist ]; then cat /etc/fail2ban/ip.blacklist | grep -e $ | cut -d , -s -f 1 | while read
IP; do iptables -I fail2ban- 1 -s $IP -j DROP; done; fi
# Option: actionstop
# Notes.: command executed once at the end of Fail2Ban
# Values: CMD
#
actionstop = iptables -D INPUT -p -j fail2ban-
iptables -F fail2ban-
iptables -X fail2ban-
# Option: actioncheck
# Notes.: command executed once before each actionban command
# Values: CMD
#
actioncheck = iptables -n -L INPUT | grep -q fail2ban-
# Option: actionban
# Notes.: command executed when banning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: IP address
# number of failures
# unix timestamp of the ban time
# Values: CMD
#
actionban = iptables -I fail2ban- 1 -s -j DROP
if ! grep -Fxq , /etc/fail2ban/ip.blacklist; then echo , >> /etc/fail2ban/ip.blacklist; fi
# Option: actionunban
# Notes.: command executed when unbanning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: IP address
# number of failures
# unix timestamp of the ban time
# Values: CMD
#
actionunban = iptables -D fail2ban- -s -j DROP
[Init]
# Option: protocol
# Notes.: internally used by config reader for interpolations.
# Values: [ tcp | udp | icmp | all ] Default: tcp
#
protocol = tcp
########################
###Zimbra Mail
#######################
[zimbra-account]
enabled = true
filter = zimbra
action = iptables-allports[name=Zimbra-account]
sendmail[name=Zimbra-account, dest=root@localhost]
logpath = /opt/zimbra/log/mailbox.log
bantime = -1
maxretry = 4
[zimbra-audit]
enabled = true
filter = zimbra
action = iptables-allports[name=Zimbra-audit]
sendmail[name=Zimbra-audit, dest=root@localhost]
logpath = /opt/zimbra/log/audit.log
bantime = -1
maxretry = 2
[postfix]
enabled = true
filter = postfix
action = iptables-multiport[name=Postfix, port=smtp, protocol=tcp]
sendmail-buffered[name=Postfix, dest=root@localhost]
logpath = /var/log/maillog
bantime = -1
maxretry = 5
Step 8 Create file in which we will save the banned ip address, after restart the script who we add before
will ban again.
Step 9 Create file in which we will save the filer rules for zimbra.
Step 10 Open the file and include the rules.This script work for Zimbra 8.X. for earlier version you
have to use this script.
[Definition]
ignoreregex =
Step 11 Create file in which we will save the banned ip address, after restart the script who we add
before will ban again.