Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 lightweight linux device which I would like to block from accessing one specific URL. Instead of making the request to the external URL, I would like to return the contents of a local file.

The most common solutions for accomplishing this seem to be:

  • Using squid (not suitable because the required resources are not available)
  • DNS blocking using /etc/hosts (not suitable because I only want to block a specific url, not an entire domain)

I am unsure whether this can be done solely using iptables? Are there any other simple solutions?

Any suggestions are appreciated.

share|improve this question

You can use iptables:

iptables -I OUTPUT -p tcp --sport 80 -m string --string "" --algo kmp -j DROP

You may also be interested in DansGuardian.

share|improve this answer

Your Answer


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.