Redirect/Block outgoing HTTP traffic for a specific URL on Mac

0

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

guillaume

Posted 2013-12-27T11:20:21.823

Reputation: 103

Answers

1

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,

REJECT

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

MariusMatutiae

Posted 2013-12-27T11:20:21.823

Reputation: 41 321

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 – 2013-12-27T12:08:36.213

@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, http://en.softonic.com/s/iptables:mac/english-mac-x. Apologies.

– MariusMatutiae – 2013-12-27T13:00:37.683

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 – 2013-12-27T13:02:18.490

@guillaume Glad to hear this. Happy New Year. – MariusMatutiae – 2013-12-27T13:05:07.903