A Firewall is very essential and critical in any Linux Distribution. It basically acts as the first line of defense against external threats and attacks. Basically, a Firewall prevents any unauthorized entity from creeping into your network. However, you can create Firewall rules to allow the access of the authorized entities to your network. This can be done by opening certain trusted ports.
Here at LinuxAPT, we shall look into allowing a UFW port on your Ubuntu system.
Easy to follow examples to Allow a Port using UFW on Ubuntu
1. How to allow a Port on Both TCP and UDP ?
Here, we will allow a port on UFW irrespective of the protocol, i.e., this port will be allowed both on TCP and UDP.
To do this, we have used the following command:
$ sudo ufw allow 53
What this command will do is to allow the opening of the port "53" on both TCP and UDP.
2. How to allow a Port on a Specific Protocol ?
Here, we will be allowing a port on a specific protocol like TCP. For that, we have used the following command:
$ sudo ufw allow 80/tcp
This command will open port "80" only for TCP.
[Need help in fixing Firewall system issues on Debian Linux ? We can help you. ]
This article covers the procedure of allowing a UFW port on Ubuntu. In fact, UncomplicatedFirewall (UFW) is a command-line, frontend iptables manager, similar to Firewalld and ConfigServer Security & Firewall (CSF).
How to Close a Port using UFW on Ubuntu ?
After you uninstall software you should close any ports you no longer need open on your system. You can accomplish this using the service name or port number.
1. To close a port in UFW using the service name:
$ sudo ufw deny pop3
2. To close a port in UFW using the port number:
$ sudo ufw deny 995
How to Check Open Ports using UFW on Ubuntu ?
1. To check whether UFW is running:
$ sudo ufw status
2. To check whether UFW is running with additional information such as logging and profile status:
$ sudo ufw status verbose
3. To find the rule number for UFW rules:
$ sudo ufw status numbered
4. Then you can remove the rule:
$ sudo ufw delete 1