Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
-A PREROUTING -s -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
-A PREROUTING -s -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8080

The above code is a code Ive used to forward traffic in linux.

Now I need to do the same thing in Mac OSX. 10.8 if it matters.

So, here is the deal.

Before, I was using a proxy to connect to the linux machine and using that proxy I was able to monitor traffic using mitmproxy

Now, on the mac, Im using the built in internet sharing and want to use mitmproxy which only listens to stuff from port 8080.

    ether ac:de:48:81:1d:4a 
    inet netmask 0xffffff00 broadcast
        priority 0 hellotime 0 fwddelay 0 maxage 0
        ipfilter disabled flags 0x2
    member: en0 flags=3<LEARNING,DISCOVER>
             port 5 priority 0 path cost 0

The above is the "shared connection" that I need to forward I believe.

share|improve this question
up vote 19 down vote accepted

Assuming all your web traffic request will be from and interface bridge0

Add following rules to /etc/pf.conf

rdr pass on bridge0 inet proto tcp from to any port http -> port 8080
rdr pass on bridge0 inet proto tcp from to any port https -> port 8080

Quick Tips

  1. Test pf.conf for syntax error

    pfctl -v -n -f /etc/pf.conf
  2. Apply/Reload the rules

    pfctl -f /etc/pf.conf

This is a cheat-sheet for OS X pfctl.

share|improve this answer
pf doesn't seem to be enabled by default, so you might have to add the -e flag: pfctl -ef /etc/pf.conf. – Webthusiast Feb 18 '14 at 9:04
it says syntax error – Hitesh Joshi Sep 14 '14 at 11:52

Your Answer


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.