I'm trying to forward any packets on port 80 from any interface to my SOCKS proxy (Server). I'm not sure if I have it set up correctly but I can't get it to forward the packets.

I create a SOCKS proxy like so on Machine A:

ssh -D 5948 user@server

This allows me to access the Internet via my SOCKS proxy if I change the proxy settings in chrome.

This is fine, except I connect a device (Device B) to Machine A using Bluetooth that I want to access the Internet via the SOCKS proxy from that device going through my machine.

           +---------------+    +---------------+    +--------------+
           |               |    |               |    |              |
           |               |    |               |    |              |
Internet   |    Server     <----+   Machine A   <----+   Device B   |
           |               |    |               |    |              |
           |               |    |               |    |              |
           +---------------+    +---------------+    +--------------+
                                                  Connected via Bluetooth

The connection and Internet sharing via bluetooth is working fine, except rather than using the SOCKS proxy it's using my ISP.

Instead what I want to do is use pf to forward any packet from any interface on port 80 to my SOCKS proxy.

I've attempted this by creating an anchor file with the following:

rdr pass inet proto tcp from any to any port 80 -> port 5948

I included the anchor in pf.conf and enable forwarding on all interfaces like so:


The forwarding isn't happening and I can only assume my pf rule is incorrect. I've validated it using:

sudo pfctl -vnf /etc/pf.anchors/org.jj.forwarding

Any ideas where I'm going wrong?


As you have enable forwarding adding a following iptable rule should work

iptables -t nat -A PREROUTING -i bl1 -p tcp --dport 80 -j DNAT --to

bl1 is your bluetooth interface

  • 1
    iptables in inappropriate. The thread starter is likely using BSD as they referred to pfctl instead of iptables or firewalld. Your answer might well work for Linux, but not for BSD – soph Mar 15 at 15:14

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.