I have to open up a group of ports.
Adding the single ports to (g)ufw was easy enough but I can't work out how to open the range
How do I do that?
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
You can specify port ranges to
ufw (the command-line one), using
: (colon) to separate the lowest and the highest port in the range. For example:
ufw allow 11200:11299/tcp
Note that the protocol part (
/udp) is mandatory with port ranges.
This works at least since Ubuntu 10.04.
ufw allowalso opens ports for IPv6 by default. May 26, 2014 at 11:00
ufw allow 11200:11299/tcp ufw allow 11200:11299/udp
or if you need to use a from source ip range you must use full syntax
ufw allow from AAA.BBB.CCC.DDD/EE to any port 11200:11299 proto tcp ufw allow from AAA.BBB.CCC.DDD/EE to any port 11200:11299 proto udp
Its worth adding that if you want to restrict to a specific IP address which is allowed access to those ports you can use the following:
ufw allow proto tcp from 22.214.171.124 to any port 40000:40100
I believe you can specify the range in the last tab of new rule, tick the checkbox at the bottom of the window to add more options (just to be safe). The range can be specified as 1000:1010 to open ports 1000-1010.
The cleanest command line way I've seen is a little script like this:
for i in `seq 11200 11299`; do ufw allow $i done