iptables rules for Mosh connections

Mosh reqires UDP 60000-61000 to be open and accent connections for it to work. Here is the iptables rule to add that:

sudo iptables -A INPUT -p udp -m multiport --dports 60000:61000 -j ACCEPT

Don’t forget to save the config once you are done, on CentOS the command to save the iptables config to disk is:

service iptables save 

Source

3 thoughts on “iptables rules for Mosh connections

    1. Stanislav Khromov Post author

      Hi Martin!

      Thanks for your comment. I’ve tried to read up on the difference between -dport and –dports but they seem to be the same command. Could you enlighten me on the difference? :-)

      Reply
  1. Martin Brampton

    Well, I’ve never used dports myself! But looking up the man page for iptables at https://linux.die.net/man/8/iptables indicates that –dports is followed by a list of up to 15 ports, separated by commas. This is different from –dport which will accept either a single port or a range of ports, separated by colon. Obviously in this case you couldn’t list out all the ports that are being enabled, so –dport is the correct option to use, along with the range.

    Reply

Leave a Reply

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

Markdown is allowed in comments.