Most of the time, we would not need this, since tunneling to a localhost is all we need to achieve our objective. Until one day, I have the requirement to actually tunnel my "behind the firewall" port to a public IP of a remote server. And here is how I do it.
Actually you can specify which IP you want the tunnel to be set up to. Let's say we want to set up a local tunnel on port 2222 of the address 10.20.30.40, connected to localhost port 22 at the remote server.
$ ssh -L 10.20.30.40:2222:localhost:22 user@remote.server.ip.address
If we want the tunnel to listen to all IPV4, we can do like below
$ ssh -L 0.0.0.0:2222:localhost:22 user@remote.server.ip.address
$ ssh -L "[::]:2222:localhost:22" user@remote.server.ip.address
If we want the tunnel to listen on all interfaces, we can do like below
$ ssh -L \*:2222:localhost:22 user@remote.server.ip.address
That's all, happy tunnelling :)
No comments:
Post a Comment