Skip to content

Instantly share code, notes, and snippets.

@ChaosJohn
Forked from jnovack/README.md
Created November 20, 2015 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChaosJohn/362d7964c28ca3dbe7cd to your computer and use it in GitHub Desktop.
Save ChaosJohn/362d7964c28ca3dbe7cd to your computer and use it in GitHub Desktop.
Opening up mosh in firewalld using firewall-cmd

Mosh (mobile shell) is a gift from the Gods(tm). Anyone with spotty internet or wireless connection has suffered the pain of a lost SSH session. Sure, one can fire up screen (or tmux as the kids are using these days), but that's an extra step and you are still using the SSH protocol.

I'm not here to tout the benefits of Mosh, you came here to open it up in your firewall.

  1. Create the following file as /etc/firewalld/services/mosh.xml
  2. firewall-cmd --reload
  3. firewall-cmd --add-service=mosh --permanent

If you tend to have a lot of sessions (not recommended), you can increase the ports, but the default should be fine for most applications.

Never, ever, ever modify the files in /usr/lib/firewalld/, they will be overwritten on upgrade. firewalld will look for any customization files in /etc/firewalld/ first for any services/ or zones/, so edit or create files there.

<?xml version="1.0" encoding="utf-8"?>
<service>
<short>MOSH</short>
<description>Mosh (mosh.mit.edu) is a free replacement for SSH that allows roaming and supports intermittent connectivity.</description>
<port protocol="udp" port="60001"/>
<port protocol="udp" port="60002"/>
<port protocol="udp" port="60003"/>
<port protocol="udp" port="60004"/>
<port protocol="udp" port="60005"/>
<port protocol="udp" port="60006"/>
<port protocol="udp" port="60007"/>
<port protocol="udp" port="60008"/>
<port protocol="udp" port="60009"/>
</service>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment