Oct 25, 2013

Port Redirection in Linux


Here's a simple Port Redirection example in Linux, I use this a lot in "work around" solutions, because it's essentially a static PAT without the need for network equipment.

From your Linux host the command is:

ssh localhost -L <LocalListeningIP>:<LocalListeningPort>:<RemoteServerIP>:<RemoteServerPort> -N

- localhost : This simply initiates the ssh session to the localhost for the port redirection to take affect.
- "-L": The switch to trigger the port redirection and accept the following variables
- LocalListeningIP : The IP address that you want to listen on.  This can be 0.0.0.0 if you want to listen to all local IPs on the system
- LocalListeningPort : The TCP Port that you want to listen to.  This can be any port.  Your internal systems will target this to reach the remote server's port.
- RemoteServerIP : The remote server's IP address that your internal systems will be targeting and redirected to.
- RemoteServerPort : The remote server's listening Port that your internal systems will need to reach.
- "-N" : This tells the system not to execute any commands once the ssh session is established.


No comments:

Post a Comment