Want to allow port range in UFW? We can help you.
UFW provides a user-friendly framework for managing Netfilter.
At Bobcares, we often receive requests regarding UFW as a part of our Server Management Services.
Today, we shall discuss how our Support Engineers allow port range in UFW.
How to allow a port in UFW
First, let’s discuss how our Support Engineers open a port in UFW.
To open a port in a server we use the command,
ufw allow 5025
If we need to open a default service port we can use the name in the command,
ufw allow ftp
This will open port 21. We can see the service that can be allowed or denied by name from /etc/services file.
How to allow port range in UFW
Recently one of our customers contacted us to allow a port range from 5025 to 5050. His application required the ports to be open to run.
Let’s discuss how our Support Engineers allow a port range for the customer.
Using UFW command
To allow port range from 5025 to 5050 in UFW, we use the command:
ufw allow 5025:5050/tcp
ufw allow 5025:5050/udp
When allowing port range we need to specify the protocol whether it is TCP or UDP. If we are not specifying the protocol when allowing a single port. Then it allows traffic from both the protocol.
When allowing a port range without the protocol. It displays a message:
ERROR: Must specify ‘TCP’ or ‘UDP’ with multiple ports
So our Engineers always make sure we add the protocol in the command.
In UFW when adding a rule it will be applicable for both ipv4 and ipv6.
Allow ports range for custom application
If a user wants to use a non-standard port to run an application. We can mention it in the application profile. When installing a package it creates an application profile in application.d directory. We can specify the port 5025 to 5050 in profile.
We add the port range in the file.
[Custom application]
title=custom application
description=custom application
ports=5025:5050/tcp|5025:5050/udp
Finally, we save the file.
We can view the application list using the command
ufw app list
[Need any assistance with UFW? – We’ll help you]
Conclusion
Today, we have discussed how to open a port in UFW. Also, we have discussed how our Support Engineers open a port range in UFW from the UFW command and for a custom application.
0 Comments