This is seldom a good idea in my opinion, because the underlying problem is rarely a technology one;
moreover you can never be absolutely sure that you are indeed blocking all traffic, stopping users that use VPNs for example is tough.
In case you have a legitimate application however, the fundamental way to do this would be to consult a database that maps ip ranges to ASs or country codes directly like this one: https://iptoasn.com/
Once you have the affected ip ranges you can block them either at level 3 in a router or at the application level.
Comments
This is seldom a good idea in my opinion, because the underlying problem is rarely a technology one; moreover you can never be absolutely sure that you are indeed blocking all traffic, stopping users that use VPNs for example is tough.
In case you have a legitimate application however, the fundamental way to do this would be to consult a database that maps ip ranges to ASs or country codes directly like this one: https://iptoasn.com/
Once you have the affected ip ranges you can block them either at level 3 in a router or at the application level.