IP Ranges is a module that let's you completely ban both single IP-addresses as well as
full ranges from your site. The ban is triggered already at the early bootstrap phase, so you
can get rid of unwanted visitors as early as possible without wasting server resources.
You can also define whitelists that override blacklists, both single and ranged.
The UI is similar to core ip-ban, so you will feel like home immediately.
Just enable the module as usual.
After enabling the module, go to admin/config/people/ip-ranges to find form where you can enter either single IP-address or IP Range, and a list type.
IP-address range is entered in the form of 100.100.100.100 - 100.100.101.150.
(This is currently the only allowed range form, other types like bitmasks may come at later stage).
Type can be either "blacklist" or "whitelist",
where blacklisted IP's are denied from the site, and whitelisted are allowed.
Whitelists always override blacklists.
Restrict IP allows you to enter whitelists. All other IP's are banned.
Unlike IP Ranges, it does not actually restrict access to the page, but rather
unsets all the regions. It also may serve pages even to banned IP:s if the requested page can be retrieved from cache. The approach is considerably more resource hungry than that of IP Ranges, but may be more pleasing to the eye of the banned user since the theme gets rendered even for them.
Troll offers blacklists(but no whitelists), and has also big array of other functionality. Seems to be abandoned but widely used. Unfortunately, no D7-version available at all, nor stable releases for any drupal version.
Countryban lets you block whole countries from either entering your site, or to give them read-only access. It uses the data from Webhosting.info to map ip-addresses to countries.