Forum Moderators: phranque
if you have mod_access [httpd.apache.org] installed you can do something like this in your .htaccess file:
order deny,allow
deny from a.b.c.d
allow from all
# Some servers will require this
Options +FollowSymlinks
# Turn on mod_rewrite
RewriteEngine On
# If the undesirable IP
RewriteCond %{REMOTE_ADDR} ^nn\.nn\.nn\.nn$
# Block it
RewriteRule .* - [F]
Replace "nn" with the numbers. The hat (^) symbol means "starts with", the dollar symbol ($) in this context means "ends with", and any line starting with a hash symbol (#) is a comment.
For a list of IPs you put them in sequential lines, with all except the last having an [OR]:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^xx\.xx\.xx\.xx$ [OR]
RewriteCond %{REMOTE_ADDR} ^yy\.yy\.yy\.yy$ [OR]
RewriteCond %{REMOTE_ADDR} ^zz\.zz\.zz\.zz$
RewriteRule .* - [F]
It is also possible to block sequential ranges of IPs in a single line using regular expressions, but .htaccess is extremely powerful and requires absolute accuracy (one character out of place and your site will be offline) so I won't go into that here - there are many examples elsewhere in the forum if you need them.
As phranque said, this is only useful for static IPs, and many people have dynamic ones.
...