I want to know if it's possible to redirect or block HTTP traffic with a string like this command on linux :

iptables -A OUTPUT -p tcp -m string --string "STRING" -j REJECT

I am not sure I understand the question.

1) If the question is is there iptables in Mac?, the answer is yes, just use this link.

2) if the question is is this correct? then the answer is not completely: why would you want to use REJECT instead of DROP? According to the Man page for iptables,


This is used to send back an error packet in response to the matched packet: otherwise it is equivalent to DROP so it is a terminating TARGET, ending rule traversal.

Do you really need the error packet?

3) The last point is: is iptables the correct instrument for Web filtering? Here the answer is most likely not. iptables is for firewalling udp/tcp traffic. If you want to do Web filtering, look at squid, privoxy,...

If however you prefer to do it this way, then the grammar of the command is well exemplified by a post on a sister site, here (see the second reply).

  • Are you sure iptables can be installed with macports ? Because I can't find it. Indeed I need a DROP and not a REJECT. I'm looking If I can do what I want with privoxy, thanks – guillaume Dec 27 '13 at 12:08
  • @guillaume You are indeed right, iptables is not in macports. It has been so long since I downloaded it that I forgot. It can be found here, en.softonic.com/s/iptables:mac/english-mac-x. Apologies. – MariusMatutiae Dec 27 '13 at 13:00
  • Oh thanks, but Privoxy work well ! And I think I'll build a tiny proxy in C++ or java to do only what I want to do – guillaume Dec 27 '13 at 13:02
  • @guillaume Glad to hear this. Happy New Year. – MariusMatutiae Dec 27 '13 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.