Again, if your system is already logging the failed log in attempts, it is an easy setup to get fail2ban working. Just search online for how to do it for the OS that you use. There are multiple how-to do it guides out there. It all depends on your OS and doesn't really have anything to do with Moodle.
There are so MANY locations trying to hack servers, that I have mine set so that if you fail to log in once, you are permanently banned. In four years, I have accidentally banned myself twice. Since that is a potential problem, you need to do like I have done and have multiple ways to log in to a terminal window on the server, so you un-ban yourself, if needed.