Routing localhost traffic to external IP address I have a host with Mac OS and another machine (192.168.100.50) in the same LAN.
I would like to configure Mac OS in that way if I access localhost:443 it will redirect to 192.168.100.50:443.

I'm able to redirect ports inside Mac OS, so if I access localhost:444 it redirects to localhost:443 this way:


sudo sysctl net.inet.ip.forwarding=1
/etc/pf.anchors/dev:


rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 443 -&gt; 127.0.0.1 port 444



/etc/pf.conf:


scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
rdr-anchor "dev"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "dev" from "/etc/pf.anchors/dev"



sudo pfctl -ef /etc/pf.conf


But if I change from any to 127.0.0.1 port 443 -&gt; 127.0.0.1 port 444 to from any to 127.0.0.1 port 443 -&gt; 192.168.100.50 port 443 it doesn't work. 

I guess I should set up NAT somehow, but I'm not sure how to do that with PF to achieve that. So any help will be very appreciated.
Ok, I finally managed to solve the task. As Bob Harris suggested on Apple's forum, I used ssh tunneling to setup it.


On Windows I use OpenSSH
On Mac OS I use Core Tunnel
Core Tunnel doesn't allow to bind to 443 port directly, so I used another port and redirected 443 to that port via PF as described in initial post.