Running Mosh behind a NAT

I recently discovered Mosh and wanted to use it with my home server. I received this message and was very frustrated since it works on my public web server:

Nothing received from server on UDP port 60001

Turns out Mosh doesn’t like NAT. The way around this is to build Mosh from source as the HEAD version in git has a “fix” for this. Here are the steps i took to do this on Ubuntu 12.04 LTS and Mac OS 10.9.1:

Ubuntu

Make sure you remove your apt-get flavored Mosh first!

Now install mosh from source:

git clone https://github.com/keithw/mosh
cd mosh
./autogen.sh
./configure
make
sudo make install

Mac OS: (Use Homebrew for dependencies)

First make sure you have Xcode command line tools

sudo xcode-select install

Then install Mosh using homebrew first. This will automagically get you all the dependencies!

brew update
brew rm protobuf
brew install mobile-shell
brew rm mobile-shell

The point of removing protobuf is because you may have it built using a previous version of Mac OS, in which case building Mosh will fail. Once you have removed Mosh, lets build the latest version from git. The steps are the same as for Linux once you have the dependencies!

git clone https://github.com/keithw/mosh
cd mosh
./autogen.sh
./configure
make
sudo make install

When you’ve done this, you need to forward UDP 60001 through your NAT. Then you just connect 🙂

mosh --bind-server=any host.domain.com -p 60001

–bind-server=any is the reason we needed Mosh from git, If brew or apt-get installs a version later than 1.2.4a by default, you probably don’t need to build it from scratch.

Good luck!

Leave a Reply

Your email address will not be published. Required fields are marked *