I'm using Apache,hosted on Linux.
Asked
Active
Viewed 172 times
2 Answers
3
/sbin/iptables -I INPUT -s A.B.C.D -j DROP

womble
- 96,255
- 29
- 175
- 230
-
Will it still work after reboot? – Dec 09 '09 at 06: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 09 '09 at 06:21
-
No, you will have to add a script thats run on boot up – artifex Dec 09 '09 at 06:21
3
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 192.168.44.201
allow from all

kolypto
- 11,058
- 12
- 54
- 66
-
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 09 '09 at 07:32
-
1@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 09 '09 at 08: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