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 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 "superuser.com" --algo kmp -j DROP

You may also be interested in DansGuardian.

share|improve this answer

You must log in to answer this question.

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