IMLC.ME
Search…
en-US
Create TCP Tunnel/Port Forwarding by SSH
An alternative way to establish TCP tunnel or port forwarding for frp.

Remote Port Forwarding

The request http://example.com:8080 will be passed to 192.168.0.101:10080.
1
# -N: Do not execute a remote command. This is useful for just forwarding ports
2
# -R: Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.
3
ssh -N -R 8080:192.168.0.101:10080 <username>@example.com
Copied!

Local Port Forwarding

The request http://192.168.0.100:10080 will be passed to 10.0.0.161:8080
1
# -N: Do not execute a remote command. This is useful for just forwarding ports
2
# -L: Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.
3
ssh -N -L 10080:example.com:8080 <username>@example.com
Copied!

Notes

You can change target ip/domain name to any other address, such as localhost or other location that server can access.
ssh -N -R 8080:localhost:10080 <username>@example.com ssh -N -R 8080:google.com:80 <username>@example.com
are both valid.

References

Last modified 1yr ago