Please suggest the easiest way to forward all connections from host:port(external interface) to host2:port(external interface)
When i use
ssh -L local_port:remote_host:remote_port -N -l user remote_host
main problem is that local_port must support connection also on external interface to allow connections not only from localhost on that machine
Thanks in advice
I'd go with either of these routes:
ssh -L 0.0.0.0:localport:remote_host:remote_port -N -l user remote_host
this way ssh will bind to all interfaces not only to the local which is only a defaultYou did not explain what are you going to use port forwarding for. So, I'd venture to propose, additionally to using
-L
flag, setting up a SOCKS proxy for applications that support it (for example Firefox):Common use is to configure Firefox to use this SOCKS proxy, with
network.proxy.socks_remote_dns
turned on, to tunnel your HTTP session through other host.You're missing the -g flag. Add that and remote hosts can use the tunnel too.
If you are using freebsd then best way is to use firewall:
INT - interface name (i.e. rl0)
this command will forward from INT:PORT1 to IP2:PORT2
It's fastest and most customizable method of forwarding ports but it's BSD-only
Check PF FAQ for more