How to Delete rules in UFW Ubuntu Firewall using ufw delete command

In This tutorial We are going to Learn How to Delete Firewall Rules in Ubuntu Firewall.

In Ubuntu Firewall, we can delete firewall rules by the rule number or the original rule by using ufw delete command.

Delete Firewall rules by rule number

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

ufw delete rule - Delete rules in UFW Ubuntu Firewall

Delete Firewall Rules using the Original rule

You may also remove rules using the original rule. Just prefix the original rule with ufw delete command. For example, if the original rule was.

ufw allow from 192.168.1.10 to any port 22 proto tcp

Then remove the firewall rule using

ufw delete allow from 192.168.1.10 to any port 22 proto tcp

Examples

ufw delete 4

Delete rule number 4 ub ufw Ubuntu Firewall.

ufw delete allow from 192.168.1.50

Delete the firewall rule, ufw allow from 192.168.1.50.

ufw delete allow from 192.168.1.10 to any proto tcp port 80

Delete the firewall rule,ufw allow from 192.168.1.10 to any proto tcp port 80.

Delete All Firewall Rules

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

ufw reset

You will have the re enable the firewall using ufw enable command.

Summary

In Ubuntu Firewall ufw delete command use to delete firewall rules. Rules can remove using either rule number or original rule.