I'd like to connect to my server which is behind the NAT through mosh. I can't touch the router to set it as upnp support, but I've apply for a UDP port forward 9807->60000, and a ssh port forward of cause.
So, is there anyway to specified the server port through command line args or conf file at client and/or server side?
Note: the following not work!!
mosh -p 9807 user@my_server
Edit:
I've try to ssh to my server first, and run mosh-server -p 60000 manually, and then mosh -p 9807 my_server from another terminal. This cause an error:
Error binding to IP my_server_ip: bind: Address already in use
That said:
- the port forward is working.
- the mosh try to install the mosh-server at port 60000.
Thanks.
The problem you're having lies in the port redirection. Your NAT forward at the router is sending incoming traffic sent to
<domain>:9807on to<internal-ip>:60000. When you start mosh with the-poption, the client connects to the server over ssh and tells the server to start, listening on the port specified. The mosh-server then communicates the open port number (in this case, the one you specified) back to the client, which closes the ssh connection and tries to connect to<domain>:<port>. The client is trying to communicate to the same port the server is listening on. The problem is that your NAT router is redirecting traffic from one port on the WAN side to a different port on the NAT'd machine. This will not work.The best thing to do would be to get a direct translation, such as requesting the router forward port 9807 on the WAN side to your mosh-server machine at port 9807.
If that is not an option, the next best thing I can think of is to mangle the traffic on the server machine using iptables.
The execute your client as you describe
What happens is:
mosh-serverlistening on port9807.980798079807and sends it to your server at port6000060000overUDP, which matches the iptables rule and get redirected to their destination (the server's IP, in this case), but at port9807