Port forwarding using SSH
Port forwarding is a technique which redirects an IP connection from one host to another. For example, if you are using a Linux/Unix system as a firewall you can redirect connections to port 1234
to an internal address such as 192.168.1.10:22
to provide an ssh
tunnel from the outside world to an internal machine.
How to do it...
You can forward a port on your local machine to another machine and it's also possible to forward a port on a remote machine to another machine. In the following examples, you will get a shell prompt once the forwarding is complete. Keep this shell open to use the port forward and exit it whenever you want to stop the port forward.
- This command will forward port
8000
on your local machine to port80
on www.kernel.org:
ssh -L 8000:www.kernel.org:80user@localhost
Replace user with the username on your local machine.
- This command will forward port 8000 on a remote machine to port
80
of www.kernel.org:
ssh -L 8000:www.kernel.org:80user...