An illustrated guide, tutorial, how-to, on ssh tunneling

There are two situations which typify the need for ssh tunneling to a computer which is publicly accessible on the Internet. Let's call this publicly accessible computer "remote.server.com":
  1. Problem: A server/service on remote.server.com is listening to port 11000. You want to use your own personal, local computer to connect to it. However, port 11000 is hidden behind remote.server.com's firewall.
    Tunneling solution: You can connect to port 22000 of your own personal, local computer and the tunnel will push it to port 11000 on remote.server.com

  2. Problem: A server/service on your own personal, local computer is listening on port 11000. You want remote.server.com to connect to your server/service. However, your personal, local computer does not have a publicly accessible address on the internet.
    Tunneling solution: remote.server.com can connect to itself on port 22000 and the tunnel will push it to port 11000 on your personal, local computer.

Here's what the command looks like for #1 when typed on your personal, local computer:

ssh -N -L 22000:localhost:11000 remote.server.com

Here's what the command looks like for #2 when typed on your personal, local computer:

ssh -N -R 22000:localhost:11000 remote.server.com

 

BONUS USAGE!!!

You've read this far, so one more useful usage we'll pretend to use

ssh -N -L 22000:192.168.1.2:11000 remote.server.com