Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a webserver running OpenSUSE 11.1 and I need to block a URL. The reason I want to block a URL is because it seems to have a different IP address all the time, but the URL stays the same.

I'd rather not install any new software, so I was hoping for a way to do this with either IPTABLES or Apache.

Would something like this work?

iptables -A INPUT -s botmasterlabs.net -j DROP
iptables -A OUTPUT -d botmasterlabs.net -j DROP

Any other ideas?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

iptables will resolve the name at the time the firewall is loaded. It won't work for servers with dynamic addresses such as you are encountering. If the problem site had a static address, you would only need the INPUT rule.

Apache rewrite should be able to do this, but will cost you a DNS lookup for each request the server responds to. Install a caching DNS server if you don't already have one. Something light-weight like dnsmasq should be sufficient for a smaller site. Something like the following should forbid access. See the URL Rewriting Guide for additional guidance.

 RewriteEngine on
 RewriteCond   %{REMOTE_HOST}  example\.com$
 RewriteRule   * - [F]
share|improve this answer
    
Thanks. Close to what I decided to use. I used httpd.apache.org/docs/1.3/mod/core.html#filesmatch and denied access. –  Bobby S Aug 3 '11 at 16:18
add comment

I suggest you use something like this in your Apache config for the virtual host in question:

RewriteEngine on
RedirectMatch /folder(.*) http://is.gd/8BhjPN

Does that work for you? Note: that redirect target may not be the exact message you want to give - you may want to throttle that up or down depending on the full context of the situation.

share|improve this answer
    
Thanks for the reply. I decided to use httpd.apache.org/docs/1.3/mod/core.html#filesmatch and deny access. –  Bobby S Aug 3 '11 at 16:18
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.