4

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.

1 Answer 1

4

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.

You must log in to answer this question.

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