UFW Remove Rule in Ubuntu 22.04 (Jammy Jellyfish) Linux system

UFW stands for uncomplicated firewall. The Ubuntu 22.04 (Jammy Jellyfish) Linux comes with packet filtering called Netfilter. The iptables frontend command used to manage netfilter. However, ufw provides easy to use front-end for netfilter, and it is one of the most popular among Ubuntu and Debian Linux sysadmins and developers.

Firewall rules can be added or omitted from the set of Firewall rules. However, at times, you accidentally add a Firewall rule, or you might not need a certain Firewall rule any longer. In both of these cases, you would feel the need to remove that particular rule.

Here at LinuxAPT, we shall look into how you can remove a UFW rule in Ubuntu.

Method to Delete a UFW Rule in Ubuntu 22.04 (Jammy Jellyfish) ?

To begin with removal of a UFW rule, you need to first add a new rule to our Firewall, which we will remove later. To add a new Firewall rule, you can execute the ufw allow command. 

For example, to add TCP port 53, you can run the below command:

$ sudo ufw allow 53/tcp

From the output, you will notice that the specified Firewall rule has been added successfully.

Now in order to remove the just added port 53 from the system's firewall, you can simply execute the below command:

$ sudo ufw delete allow 53/tcp

You will see that the Firewall rule has been removed successfully from examining the output.

[Need help in fixing Ubuntu Linux system issues ? We can help you. ]

This article covers how you can easily delete any UFW rule from Ubuntu system firewall. In fact, In Ubuntu Firewall, we can delete firewall rules by the rule number or the original rule by using ufw delete command.

How to find the corresponding firewall rule number using ufw on Ubuntu ?

Easiest and best method is to remove firewall rules by the rule number. We can find the corresponding rule number using ufw status numbered command:

$ ufw status numbered

Then Delete the rule using ufw delete command. or example, if you want to delete rule number '2', execute:

$ ufw delete 2

How to Delete All Firewall Rules on Ubuntu ?

The ufw reset command will remove all firewall rules and also it will disable the UFW on Ubuntu.

$ ufw reset

Related Posts