Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using Apache,hosted on Linux.

share|improve this question

2 Answers 2

/sbin/iptables -I INPUT -s A.B.C.D -j DROP

share|improve this answer
Will it still work after reboot? –  PHP Dec 9 '09 at 6:18
@PHP: nope, you'll need to add the command to an /etc/rc.local or /etc/rc.firewall script to make sure it's run on reboot (and/or firewall restart). –  quack quixote Dec 9 '09 at 6:21
No, you will have to add a script thats run on boot up –  artifex Dec 9 '09 at 6:21

womble's answer will block these users from even sending requests tou your server. If you want them to see the 403 Access Denied Apache error page, put this in .htaccess file:

order allow,deny
deny from
allow from all
share|improve this answer
The problem with this solution is it will only fix a single vhost/site. Using womble's solution is server-wide and much more efficient. –  Keiran Holloway Dec 9 '09 at 7:32
@Keiran: they're very different solutions; if you're using multiple vhosts, obviously you'd need to include this multiple places. the solution stands tho: if you want the IP to see an Apache error, you need to block it in Apache. if you don't want traffic from the IP going anywhere, the iptables solution is appropriate. –  quack quixote Dec 9 '09 at 8:39
This solution is good and will work even if you have several vhosts. Just put it in the global configuration file, not in a .htaccess. –  bortzmeyer Dec 22 '09 at 20:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.