Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 -j DROP
iptables -A OUTPUT -d -j DROP

Any other ideas?

share|improve this question
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 and denied access. – Bobby S Aug 3 '11 at 16:18

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

RewriteEngine on
RedirectMatch /folder(.*)

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 and deny access. – Bobby S Aug 3 '11 at 16:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .