Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
1  
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
2  
Or is what you are asking is that you would like to block incoming links from a website domain.com? –  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
add comment

migrated from stackoverflow.com Nov 3 '10 at 4:08

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

3 Answers

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:

<Limit GET HEAD POST>
order allow,deny
deny from 62.89.0.0/19
deny from 77.95.184.0/21
deny from 80.86.224.0/20
#
# more here if you wanted
#
allow from all
</LIMIT>

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

share|improve this answer
add comment

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 (136.129.4.0-136.129.4.255) 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 136.129.4.0/8 -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
add comment

@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
add comment

Your Answer

 
discard

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