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

I would like to block traffice from What is the best way to do that?

share|improve this question

migrated from Nov 3 '10 at 4:08

This question came from our site for professional and enthusiast programmers.

Hmmm.. Traffic doesn't really come from a domain, it's comes from an IP address. – Christopher Edwards Nov 2 '10 at 20:00
Yeah, what do you mean? – Pekka 웃 Nov 2 '10 at 20:00
Or is what you are asking is that you would like to block incoming links from a website – Christopher Edwards Nov 2 '10 at 20:00
I was assuming that OP was looking for an .htaccess solution since he tagged it as such. I'm sure he is sitting on a shared hosting account with minimal or no access to firewall settings. – Urda Nov 2 '10 at 20:13

3 Answers 3

Well I'll figure you know the IP's you would like to block (you can obtain them from the domain name), so just add something to your htaccess like the following:

order allow,deny
deny from
deny from
deny from
# more here if you wanted
allow from all

If you need to find the IP of a domain you can just use this simple tool!

share|improve this answer

If you have access to the server configuration, set up an iptables rule. If you don't, use a .htaccess-file. Example for blocking an IP range ( using iptables until the next reboot (you have to do this as root)(to make it permanent, you have to put it in an initscript):

iptables -A INPUT -s -j DROP

For a htaccess example, see Urdas post - but htaccess just forbids http access, iptables completely discards all incoming traffic from the selected IPs.

share|improve this answer

@thejh your method is correct but your allocating more memory than you should be, this can be used against you in the case of a DoS

iptables -I PREROUTING -t mangle -p tcp --dport 80 -s $IP -j DROP
share|improve this answer

Your Answer


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