[mosh-devel] Using mosh-server behind a NAT router
bert at w3.org
Thu Sep 20 19:01:26 EDT 2012
I wanted to mosh into a server behind a NAT router. No doubt I could add
port redirects, but I thought that should not be needed: mosh-server can
create its own redirection via UPnP (assuming the router supports that).
I did some experiments and indeed it works. However, my code is in the
form of a wrapper around mosh-server, written in Bash. So more of a
prototype than a patch.
I think it would be nice if mosh offered an option --nat or something
similar, which directs mosh-server to try and open a port via UPnP. But
I'm not offering to write the code.
My wrapper (attached) works as follows:
If mosh was called with an option -p, then use that port, otherwise try
a number of ports until one is found that isn't yet in use.
To check if a port is in use, test two things: see if there is already a
server on this machine listening on that port, and see if there is
already a port redirect for that port on the router.
Once the port has been chosen, ask the router via UPnP to redirect that
port to this machine, then start mosh-server. When mosh-server ends,
send another UPnP command to delete the port redirection again. (That
part is a bit ugly in my wrapper code, but it would be easy to add in
mosh-server itself, just after it prints "mosh-server is exiting.")
Bert Bos ( W 3 C ) http://www.w3.org/
bert at w3.org 2004 Rt des Lucioles / BP 93
+33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1631 bytes
Desc: not available
Url : http://mailman.mit.edu/pipermail/mosh-devel/attachments/20120920/f3266b23/attachment.bin
More information about the mosh-devel