How to manage range of ports in UFW

If you want to setup firewall rule with UFW use the one of the following procedure

Solution 1

You can install gufw to manage UFW through GUI

sudo apt-get install gufw

Solution 2

If you want to Open tcp range from 33400 to 33444

Use the following syntax from your terminal

ufw allow proto tcp to any port 33400:33444

Solution 3

1) First you need to edit /var/lib/ufw/user.rules file

gksudo gedit /var/lib/ufw/user.rules

Now you need to add your rule after ### RULES ###

# Test rule to Open tcp range from 33400 to 33444
-A ufw-user-input -p tcp --dport 33400:33444 -j ACCEPT

Sponsored Link

You may also like...

4 Responses

  1. Jamie Strandboge says:

    Editing user.rules directly is not recommended because the file is managed by ufw and these changes will be lost the next time a rule is added, modified or removed via ufw or gufw. Please use solution 1 or 2 instead.

  2. Gilbert Dion says:

    There is a type in the command line:

    gksuo gedit /var/lib/ufw/user.rules

    gksuo should be gksudo…

  3. admin says:

    Updated main article.Thanks for your comment

  4. Jason Fulton says:

    The ufw sytanx to use is:

    ufw allow 33400:33444/tcp

    Hope that helps someone.

Leave a Reply

Your email address will not be published.