Do a local port redirection?

Hello.
I'm running a program on a local computer that is accessed from users remotely. For security reasons, I don't want to use the default port that the program listens to for connections, but unfortunately, I can't change the port the program listens on. As well, the firewall I'm using (a SonicWall) doesn't allow redirection from one port to another (it only allows port forwarding, but I can't have it listen on one port and then redirect to another port on the local machine - very annoying and limiting). So, I'm wondering if anyone knows if there's a local file I can edit that will solve this issue.

Basically, it's like this:

- Firewall listening on port 5002
- accepts outside connection on that port and forwards to local machine on port 5002
- I need the local machine to then redirect that connection from port 5002 to port 5004 (on itself)

Anyone know how I'd go about doing this?

Thanks,
Kristin.

20" Intel iMac 2.16 Ghz, 12" PowerBook G4 1.33 Ghz, Power Mac G4 667 Mhz, Mac OS X (10.5.6), Xserves (Early 2009, Early 2008, G5), Mac Pro

Posted on May 13, 2009 10:05 AM

Reply
4 replies

May 13, 2009 10:25 AM in response to kristin.

This may not be the most efficient, but you could setup a local ssh tunnel

ssh -g -N -n -L 5002:localhost:5004 localhost &

Connections to port 5002 on that system will be tunneled to port 5004. Make any port substitutions you desire. See "man ssh" for more information about the ssh command.

NOTE: ssh only works for TCP connection, not UDP. This is generally not a problem except for things that like to use streaming protocols.

Now there may be a REAL networking based solution, I just do not know much about the configuration of low level networking stuff.

May 13, 2009 12:10 PM in response to kristin.

Is that a one time, run that command on the local machine fix?

Once per boot, assuming you find a way to get it executed when the system boots. I know there are ways to have something run when booting, I'm just not sure what it is called (MacOSXHints.com may have some ideas or look at launchd).
Would that also mean all of that traffic would go through ssh?

Yup. So there would be additional overhead. I did say this was not the most efficient approach 🙂

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Do a local port redirection?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.