0

I am running macOS Mojave 10.14.6.

I have an app that is looking for a service hosted on localhost:9999, but I am hosting this service on a different server at 12.3.4.5:8000. How can I setup firewall rules, dns rules, or some other option, in order to redirect all requests to localhost:9999 on my machine to go to 12.3.4.5:8000?

I found many questions asking how to redirect requests to a domain to localhost, but that is the opposite of what I am looking for. I want to redirect requests from localhost to a domain (or ip):

I found this question when searching but it is not the same question as I am asking: Can I specify a port in an entry in my /etc/hosts on OS X? I also tried to use ifconfig and pfctl as in this answer to fit my case but I was unable to make it work: iptables equivalent for mac os x

1 Answer 1

0

Assuming that you want to route TCP traffic and that your server has SSH access, you can use an SSH tunnel:

ssh -L 9999:12.3.4.5:8000 remote-server-user@12.3.4.5

Then all traffic to localhost:9999 is tunneled to 12.3.4.5:8000

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.