Fail2ban is an
intrusion prevention software framework. Written in the
Python programming language, it is designed to prevent against
brute-force attack
In cryptography, a brute-force attack consists of an attacker submitting many passwords or passphrases with the hope of eventually guessing correctly. The attacker systematically checks all possible passwords and passphrases until the correct ...
s.
It is able to run on
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inte ...
systems that have an interface to a packet-control system or firewall installed locally, such as
iptables
iptables is a user-space utility program that allows a system administrator to configure the IP packet filter rules of the Linux kernel firewall, implemented as different Netfilter modules. The filters are organized in different tables, which ...
or
TCP Wrapper
__NOTOC__
TCP Wrappers (also known as tcp_wrappers) is a host-based networking ACL system, used to filter network access to Internet Protocol servers on (Unix-like) operating systems such as Linux or BSD. It allows host or subnetwork IP addresse ...
.
Functionality

Fail2ban operates by monitoring
log files
In computing, logging is the act of keeping a log of events that occur in a computer system, such as problems, errors or just information on current operations. These events may occur in the operating system or in other software. A message or l ...
(e.g. , , etc.) for selected entries and running scripts based on them.
Most commonly this is used to block selected
IP address
An Internet Protocol address (IP address) is a numerical label such as that is connected to a computer network that uses the Internet Protocol for communication.. Updated by . An IP address serves two main functions: network interface ident ...
es that may belong to
hosts
A host is a person responsible for guests at an event or for providing hospitality during it.
Host may also refer to:
Places
*Host, Pennsylvania, a village in Berks County
People
* Jim Host (born 1937), American businessman
* Michel Host ...
that are trying to breach the system's security. It can ban any host IP address that makes too many login attempts or performs any other unwanted action within a time frame defined by the administrator. Includes support for both IPv4 and IPv6. Optionally longer bans can be custom-configured for "recidivist" abusers that keep coming back.
Fail2ban is typically set up to unban a blocked host within a certain period, so as to not "lock out" any genuine connections that may have been temporarily misconfigured. However, an unban time of several minutes is usually enough to stop a network connection being
flooded
A flood is an overflow of water ( or rarely other fluids) that submerges land that is usually dry. In the sense of "flowing water", the word may also be applied to the inflow of the tide. Floods are an area of study of the discipline hydrolog ...
by malicious connections, as well as reducing the likelihood of a successful
dictionary attack
In cryptanalysis and computer security, a dictionary attack is an attack using a restricted subset of a keyspace to defeat a cipher or authentication mechanism by trying to determine its decryption key or passphrase, sometimes trying thousands o ...
.
Fail2ban can perform multiple actions whenever an abusive IP address is detected: update
Netfilter/iptables
Netfilter is a framework provided by the Linux kernel that allows various networking-related operations to be implemented in the form of customized handlers. Netfilter offers various functions and operations for packet filtering, network addr ...
or
PF firewall rules,
TCP Wrapper
__NOTOC__
TCP Wrappers (also known as tcp_wrappers) is a host-based networking ACL system, used to filter network access to Internet Protocol servers on (Unix-like) operating systems such as Linux or BSD. It allows host or subnetwork IP addresse ...
's table, to reject an abuser's IP address; email notifications; or any user-defined action that can be carried out by a Python script.
The standard configuration ships with filters for
Apache,
Lighttpd
lighttpd (pronounced "lighty") is an open-source web server optimized for speed-critical environments while remaining standards-compliant, secure and flexible. It was originally written by Jan Kneschke as a proof-of-concept of the c10k problem � ...
,
sshd,
vsftpd,
qmail
qmail is a mail transfer agent (MTA) that runs on Unix. It was written, starting December 1995, by Daniel J. Bernstein as a more secure replacement for the popular Sendmail program. Originally license-free software, qmail's source code ...
,
Postfix and
Courier Mail Server
The Courier Mail Server is a mail transfer agent (MTA) server that provides SMTP, IMAP, POP3, SMAP, webmail, and mailing list services with individual components. It is best known for its IMAP server component.
Courier can function as an intermed ...
. Filters are defined by Python
regexes, which may be conveniently customized by an administrator familiar with regular expressions.
A combination of a filter and an action is known as a "jail" and is what causes a malicious host to be blocked from accessing specified network services.
As well as the examples that are distributed with the software, a "jail" may be created for any network-facing process that creates a log file of access.
Integrations
Fail2ban can be integrated with many
APIs
Apis or APIS may refer to:
* Apis (deity), an ancient Egyptian god
* Apis (Greek mythology), several different figures in Greek mythology
* Apis (city), an ancient seaport town on the northern coast of Africa
**Kom el-Hisn, a different Egyptian ci ...
, including blocklist.de and AbuseIPDB.
Shortcomings
* Fail2ban fails to protect against a distributed brute-force attack. However, tools exist to distribute ban/unban events among servers using zmq.
* There is no interaction with application-specific
API
An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
s/AGIs.
See also
*
DenyHosts, a log-based intrusion-prevention security tool
*
Stockade, a rate-limiting approach to spam mitigation.
*
OSSEC, an open-source host-based intrusion-detection system.
References
External links
* {{Official website
Debian popularity contest results for fail2ban
Free software programmed in Python
Computer network security
Computer security software
Internet Protocol based network software
Free network-related software
Free security software
Linux security software
Brute force blocking software