I suggest you see here the most effective and efficient method to block an IP under LINUX, namely the use of IPSET.
The blocking is then done dynamically, namely that everything added to the IPSET list is immediately blocked.
The installation is done in single line:
With the SHOREWALL firewall :
First step we create an empty IPSET list named « banthis » :
Now we can enable it into SHOREWALL rules, note that the prefix for IPSET list is the caracter « + » :
With the UFW firewall :
File : /etc/ufw/after.init
We insert rules for persistence :
Test :
If you want a « test server » you can use :
https://www.thc.org/segfault/