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 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

1 Answer 1

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

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.