Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Subscribe to RSS feed


iptables rules for Mosh connections

Stanislav KhromovStanislav Khromov

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

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

Comments 3
  • Martin Brampton
    Posted on

    Martin Brampton Martin Brampton

    Reply Author

    Helpful, but should be –dport (no s)


    • Stanislav Khromov
      Posted on

      Stanislav Khromov Stanislav Khromov

      Reply 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? :-)


  • Martin Brampton
    Posted on

    Martin Brampton Martin Brampton

    Reply Author

    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.