Estamos levando em consideração que você já tem os requisitos como iptables e etc instalado no seu servidor.
Instalação:
Instalando o repositório (se não tiver instalado)
| 
					 1  | 
						yum install epel-release  | 
					
Instalando o fail2ban
| 
					 1  | 
						yum install fail2ban  | 
					
Ativando o serviço
| 
					 1  | 
						systemctl enable fail2ban  | 
					
Copie o arquivo jail.conf para jail.local
| 
					 1 2  | 
						cd /etc/fail2ban cp jail.conf jail.local  | 
					
Agora você deve abrir o jail.local e fazer as configurações que achar necessário. O arquivo é bem comentado. Abaixo colocamos apenas um trecho do arquivo que habilitamos para nossos testes.
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52  | 
						[sshd] # To use more aggressive sshd filter (inclusive sshd-ddos failregex): #filter = sshd-aggressive port    = ssh logpath = %(sshd_log)s backend = %(sshd_backend)s enabled	= true [apache] port     = http,https logpath  = %(apache_error_log)s enabled = true filter = apache-auth maxretry = 6 [apache-badbots] # Ban hosts which agent identifies spammer robots crawling the web # for email addresses. The mail outputs are buffered. port     = http,https logpath  = %(apache_access_log)s bantime  = 172800 maxretry = 1 enabled = true [apache-noscript] enabled = true port     = http,https logpath  = %(apache_error_log)s maxretry = 6 [apache-overflows] enabled = true port     = http,https logpath  = %(apache_error_log)s maxretry = 2 [apache-nohome] enabled = true port     = http,https logpath  = %(apache_error_log)s maxretry = 2 [apache-botsearch] enabled = true port     = http,https logpath  = %(apache_error_log)s maxretry = 2  | 
					
Com o arquivo salvo execute:
Para reiniciar o serviço
| 
					 1  | 
						service fail2ban restart  | 
					
Verifique se o serviço var dar como running
| 
					 1 2 3 4 5 6 7 8  | 
						# service fail2ban status Redirecting to /bin/systemctl status fail2ban.service â fail2ban.service - Fail2Ban Service    Loaded: loaded (/usr/lib/systemd/system/fail2ban.service; enabled; vendor preset: disabled)    Active: active (running) since Tue 2019-05-21 19:10:31 -03; 33min ago      Docs: man:fail2ban(1)   Process: 7255 ExecStop=/usr/bin/fail2ban-client stop (code=exited, status=0/SUCCESS)   Process: 7279 ExecStart=/usr/bin/fail2ban-client -x start (code=exited, status=0/SUCCESS)  | 
					
Verifique que jails estão ativos
| 
					 1 2 3 4 5  | 
						fail2ban-client status Status |- Number of jail:      7 `- Jail list:   apache, apache-badbots, apache-botsearch, apache-nohome, apache-noscript, apache-overflows, sshd  | 
					
Para verificar o status de um jail em específico use o nome do mesmo no comando abaixo.
| 
					 1  | 
						fail2ban-client status apache-badbots  | 
					
Para bloquear um IP em um Jail por exemplo …
Depois rode o comando do Status para vc verificar … 
| 
					 1  | 
						fail2ban-client set apache-badbots banip 10.1.1.1  | 
					
Para desbloquear um IP de um jail …
Depois rode o comando do Status para vc verificar … 
| 
					 1  | 
						fail2ban-client set apache-badbots unbanip 10.1.1.1  |