Install

yum install epel-release

yum install fail2ban

Setting

edit /etc/fail2ban/jail.conf

change these

  • ignorecommand
  • bantime
  • findtime
  • maxretry

and find what service do you want to monitor

in this case, I want setting MongoDB

[mongodb-auth]
enabled = true
port     = 27017
logpath  = /var/log/mongodb/mongod.log

Service Setting

  • enabled service when start vm
    • systemctl enable fail2ban
  • start service
    • systemctl start fail2ban
  • check fial2ban monitor your service
    • systemctl status fail2ban
  • check fail2ban jail service
    • fail2ban-client status mongodb-auth
Status for the jail: mongodb-auth
|- Filter
|  |- Currently failed:	0
|  |- Total failed:	0
|  `- File list:	/var/log/mongodb/mongod.log
`- Actions
   |- Currently banned:	0
   |- Total banned:	0
   `- Banned IP list: