I am experimenting a bit with ssh port forwarding and I stumbled upon a confusing thing. It seems to me that the following commands are doing the same thing:
ssh -NfL 192.168.121.215:2222:vm2.local:22 vm2.local
ssh -NfL 192.168.121.215:2223:localhost:22 vm2.local
ssh -NfL 192.168.121.215:2224:vm2.local:22 localhost
Connecting to pots 2222, 2223 and 2224 from pc brings me all to vm2.local.
$ ss -antp # on vm1.local (192.168.121.215)
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 192.168.121.215:2222 *:* users:(("ssh",10170,4))
LISTEN 0 128 192.168.121.215:2223 *:* users:(("ssh",10178,4))
LISTEN 0 128 192.168.121.215:2224 *:* users:(("ssh",10225,4))
LISTEN 0 128 *:22 *:* users:(("sshd",836,3))
...
What is the difference between the above commands? Is the tunnel created somewhat different? The first command is correct according to man pages, the second is from some website and the last is error I made that turned out working too.
vm2.local
andlocalhost
being the same, those are indeed, the same exact command, you'll connect local port 2222 to 2224 to 22 on localhost.