How to open a port in UFW
UncomplicatedFirewall (UFW) is a command-line iptables manager which comes with Ubuntu/Mint operating systems by default.
This article explains the details to open a port in UFW.
To open a port in UFW, the following command be used.
#ufw allow PORT
Where we need to replace PORT with the require port number.
Note that we can specify the protocol along with this command as optional.
#ufw allow PORT/PROTOCOL
Where we need to replace PORT with the required port number and PROTOCOL with either TCP or UDP as required.
If the application which using the port is already added as a service, the following command be used to open the port.
#ufw allow SERVICE
Where SERVICE need to be replaced with the name of the required service.
Note that we can specify the protocol along with this command as optional.
#ufw allow SERVICE/PORT
Where SERVICE need to be replaced with the name of the required service and PROTOCOL with either TCP or UDP as required.
If the port need to be open for a specific ipaddress, the following command be used.
#ufw allow from IP to any port PORT
Where IP need to be replaced with the source ipaddress and PORT need to be replaced with the required port number.
Note that we can specify the protocol along with this command.
#ufw allow from IP to any port PORT/PROTOCOL
Where IP need to be replaced with the source ipaddress, PORT need to be replaced with the required port number and PROTOCOL with either TCP or UDP as required.
If its required to allow all the connections from an ipaddress, the following command be used.
#ufw allow from IP
Where IP need to be replaced with the source ipaddress.
If its required to allow all the connections from a subnet, the following command be used.
#ufw allow from SUB
Where SUB need to be replaced with the source subnet.
That's all…