Linux – How to auto-block IPs attacking the server

linuxSecurityweb-server

It seems that some script kiddie started attacking one of my servers by trying to fetch all sorts of URLs that may be related to WordPress vulnerabilities. I don't even have WP installed on the server, and all these cause is a bunch of 404 errors.

Since I have my server set up to email me for each 404 error (which until now, for years, has worked very well to catch an occasional broken link), these attacks not only put load on the server but also flood my inbox.

Is there some reliable software that can block IPs that display a malicious behavior? Hopefully, at the iptables or nginx level…

Even better, is there some service that plugs into a community database that can preemptively block an IP that has recently been detected by another server as having malicious activity originating from it?

Best Answer

You can use fail2ban to monitor your logs and create custom iptables rules that deny access from specific hosts - you should find this in your distro's repository.