Blocking IP addresses in an .htaccess file? That's literally* what a firewall is for.
*metaphysically?