In the past, you may have add a rule to the UFW firewall and you no longer want those rules to be in effect.
So in that case, you can remove the rule from your firewall. In this quick guide, I will be showing easy steps to do so.
How to remove a rule from UFW Firewall
I have divided this guide into 3 simple steps so that you can have a clear idea.
Step 1: List available rules with numbers
You may be wondering why to list rules with numbers. Well, having numbers associated with a rule is helpful when one wants to remove a rule.
To list ufw rue with numbers, use the following command:
sudo ufw status numbered
And it will present every firewall rule with a natural number.
From here, note a number that is related to the rule you want to delete.
Step 2: Delete the UFW Firewall rule
Once you know the number, all you have to do is follow the given command and the rule will be removed:
sudo ufw delete number_of_rule
So let's say I want to remove a rule that allows HTTP (one of the most common ports that use port 80 by default) on my network.
And in that case, I'm required to append the associated number with that rule (number 2 in my case):
sudo ufw delete 2
It will ask your permission before removing the rule. Press
y and hit enter.
Step 3: Verify the rule deletion
To verify whether the rule was removed successfully, it is advised to check the status of ufw firewall and list available rules:
sudo ufw status
And as you can clearly see, the rule no longer exists! You have successfully delete the rule from the UFW firewall.
More on UFW...
Here's a quick summary of useful UFW commands.
If you want, you can download the above table in PDF format for quick reference in the future.
If you want details on the UFW commands, refer to this guide 👇
I hope you will find this guide helpful and if you have any queries, let me know in the comments.