What is the difference between local and remote IP forwarding?
Solution 1:
The major practical difference, is that if connecting 2 computers A and B, and B is behind a firewall or NAT Router that you don't control, and it's blocking incoming.. You're sitting at A. You can't get A to connect to B. But B won't block outgoing.. So you get B to connect to A.
--added clarification--
The above, which the questioner understood.. means the major practical difference between local and remote forwarding. ssh -L and ssh -R when you'd use each. I wasn't commenting on the specific example commands he gave, where he switches -L and -R, and which sshd server he connects to. But now I will attempt to comment on it.. With the ssh commands he gave, from the perspective of the regular client and regular server, there appears to be no difference,as it doesn't say "ah this is an ssh client and this is an ssh server.." it doesn't know ssh , and which is the client/server aspect of ssh is irrelevant and unknown to the regular client and regular server too. They just care about who is listening, and from their perspective, it looks the same. The work computer is listening and on 1234. They don't notice that in one case it's an sshd.exe ssh server, and in the other case it's an ssh.exe, ssh client. By the way, where the ssh client is, is considered local.
Solution 2:
Yes, if I understand it correctly, local port forwarding from a to b should be identical to remote port forwarding from b to a (and vice versa). An outgoing tunnel from a to b (viewed from a) should be equal to an incoming tunnel from a to b (viewed from b).
Local port forwarding creates an outgoing tunnel which can be used to bring a public internet computer to local machine. A local user can access a remote host:port combination on a local host, because the given port on the local (client) host is forwarded to the given host and port on the remote side:
ssh -L local_port:remote_host:remote_port user@hostname
Remote port forwarding creates an incoming tunnel which can be used to bring a local computer into the public internet. An internet user can access a certain local host:port combination on a remote host. The given port on the remote (server) host is forwarded to the given host and port on the local side:
ssh -R local_port:remote_host:remote_port user@hostname
Solution 3:
With local port forwarding you (the client) open a listening socket on your computer and connect your application-level protocol client to this socket. Now the connection is forwarded over SSH to the server. The server connects to the remote host and tunnels the data from your protocol client to the final destination.
With remote port forwarding the server opens a listening socket on the server host. Some remote application connects to this host and sends information which is transferred to your client computer. Here the connection is established to the final destination (some application-level protocol server running on your computer or on your network) and the data is transferred from remote application to the final destination.