# sudo apt-get update
# sudo apt-get install fail2ban
# cp sudo nano /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# sudo nano /etc/fail2ban/jail.conf
ignoreip = 127.0.0.1/8
ignoreip = 127.0.0.1/8 111.222.333.444
bantime = 600
findtime = 600
maxretry = 3
destemail = root@localhost
sendername = Fail2Ban
mta = sendmail
# sudo nano /etc/aliases
# See man 5 aliases for format
postmaster: root
root: your@email.com
action = $(action_)s
action = $(action_mwl)s
[ssh]
enabled = true
...
ls /etc/fail2ban/filter.d
# sudo apt-get install iptables-persistent
# sudo dpkg-reconfigure iptables-persistent
# sudo service fail2ban start
# sudo iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-N fail2ban-apache
-N fail2ban-ssh
-A INPUT -p tcp -m multiport --dports 80,443 -j fail2ban-apache
-A INPUT -p tcp -m multiport --dports 22 -j fail2ban-ssh
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -j DROP
-A fail2ban-nginx-http-auth -j RETURN
-A fail2ban-ssh -j RETURN