5

I'd like to forward several ports from my local machine to a remote machine through SSH tunneling. However, I want this to happen across a single port. Is there a protocol or tool that can multiplex between a single port and multiple applications?

Edit: I am forwarding a lot of ports from a lot of machines to a single remote, and I want to multiplex them at the application level per machine to use as few ports on that remote as possible. I see solutions like sshl that can multiplex certain protocols, but I don't know of any generic solutions that can wrap the messages in a protocol-independent way.

0

1 Answer 1

4

SSH lets you specify multiple ports on the command line to tunnel (example from here):

$ ssh -L 10001:one.securedomain.com:3389 -L 10002:two.securedomain.com:3389

Are you saying you only want to use a single local port?

SSH simply makes a mapping of source port <-> destination port. You have a fundamental problem if you want 1 source port <-> multiple destination ports - e.g. if you send traffic to your local port 10001, how is anything (much less SSH) supposed to know what destination port you want?

Some protocols have a feature where part of the data transmitted as payload specifies the destination of the payload. HTTP does this with the Host: header. Since SSH adopts the Unix philosophy of "X is my job and nothing else", it does not sniff, decode, or understand the traffic it's tunneling. So it can't help you, but a proxy server running on the source or destination system might. For protocols other than HTTP you have to look or develop a service that serves as a "multiplexing" proxy - I think there are utilites for SMTP and possibly FTP if you look hard enough.

One way out is to run something like OpenVPN over your SSH tunnel, in this way you can explicitly control routing and such after the traffic reaches the other side.

1
  • 1
    Yes, I only want to use a single port (remote, not local). The issue is that I am forwarding a lot of ports from a lot of machines to a single remote, and I want to multiplex them at the application level per machine to use as few ports on that remote as possible. I see solutions like sshl that can multiplex certain protocols, but I don't know of any generic solutions that can wrap the messages in a protocol-independent way. Edited my question to include this!
    – szxk
    Mar 16, 2016 at 16:20

Not the answer you're looking for? Browse other questions tagged .