SSH Local Port Forwarding
To use SSH to forward local ports to an address use the -L option.
ssh -L [LOCAL_IP:]LOCAL_PORT:DESTINATION:DESTINATION_PORT [USER@]SSH_SERVER
- [LOCAL_IP] LOCAL_PORT - the local machine IP and port. This will be how you connect to the forwarded address
- DESTINATION:DESTINATION_PORT - the IP or host name of the destination machine.
- [USER@] SERVER_IP - the remote SSH user and server IP address
Example:
ssh -L 9999:localhost:80 192.168.4.1
In the above example an SSH local forward is established on the localhost on port 9999 and connects to remote machine at 192.168.4.1:80. Now all traffic for the remote machine can be routed via the localhost address of localhost:9999
.
See Also: