1

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:

  1. sudo sysctl net.inet.ip.forwarding=1

  2. /etc/pf.anchors/dev:

rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 443 -> 127.0.0.1 port 444
  1. /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"
  1. sudo pfctl -ef /etc/pf.conf

But if I change from any to 127.0.0.1 port 443 -> 127.0.0.1 port 444 to from any to 127.0.0.1 port 443 -> 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.

  • I'm not sure that this is possible, you might be better off assigning your Mac a fixed IP address and then redirecting that IP/Port combination elsewhere. 127.0.0.1 is a special and reserved address that is baked into every networkable device, unless I am sadly mistaken changing its behavior might be a bad thing. – Steve Chambers May 1 at 13:28
  • Actually, I'm interested in assigning external IP to localhost name, not 127.0.0.1. Do you think it's impossible? – Sergey Zwezdin May 1 at 13:44
  • they are the same thing – Steve Chambers May 1 at 13:45
  • Actually, Parallels doing it somehow. They are able to route localhost's port to VM. – Sergey Zwezdin May 1 at 13:47
1

Ok, I finally managed to solve the task. As Bob Harris suggested on Apple's forum, I used ssh tunneling to setup it.

  1. On Windows I use OpenSSH

  2. On Mac OS I use Core Tunnel

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .