mobile-shell / mosh

Mobile Shell
https://mosh.org
GNU General Public License v3.0
12.43k stars 727 forks source link

allow client-side port or port range to be specified #365

Open ott2 opened 11 years ago

ott2 commented 11 years ago

It would be useful if mosh allowed the client port, or port range, to be specified. The envisaged scenario is something like:

  1. set up firewall to pass through UDP port 60001
  2. mosh -p 60001 -P 60001 server.example.com.

or with port ranges:

  1. set up firewall to pass through UDP ports 6[01]000
  2. mosh -p 60000:61000 -P 60000:61000

Mosh currently uses a system-assigned port number for mosh-client. It is therefore not possible to tunnel mosh through stateless firewalls, unless they are set up to allow essentially all UDP through.

(This scenario is common for DNS. For instance, a BIND name server can be configured to always use source port 53 when acting as a client, allowing a port 53-only UDP pass-through on the firewall.)

The code for server-side port ranges is already in place, via try_bind(), although this is not currently exposed to the user. What seems to be required is a modification to the client's Connect() to call try_bind() with a port or port range, if specified.

yaniv-aknin commented 11 years ago

+1

JustRamires commented 11 years ago

I've tried to modify source code(https://github.com/JustRamires/mosh/commit/3d0381938573c0f7ced3a201e916c3946fc1300c). But when I try to start mosh-client I get the "MOSH_KEY environment variable not found" error. And I can't change mosh because I don't know Perl(The script doesn't pass the port range to mosh-client). How can I test my changes?

sinkers commented 11 years ago

+1 Mosh looked cool but without a way to get through a firewall it makes it pretty much unusable in a corporate environment

andersk commented 11 years ago

Duplicate of #296 (now closed).

cgull commented 8 years ago

Actually, this is not a duplicate of #296; that's about specifying a server side port range, this is about specifying a client side port or port range.

eminence commented 6 years ago

530 is one solution (though it doesn't expose a command line parameter like this issue suggests)

achernya commented 1 year ago

Adding a --client-bind= would be a reasonable spelling.