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

Incoming search terms:

Related posts

4 thoughts on “How to manage range of ports in UFW

  1. 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. There is a type in the command line:

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

    gksuo should be gksudo…


    admin Reply:

    Updated main article.Thanks for your comment


Leave a comment

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