Deleting Rules

Updated on 28 Mar 2022

Status (numbered)

In the previous tutorial we added a rule to allow SSH in from a specific IP address. If we use the numbered option with the status command, we’ll be able to see a numbered list of the rules.

ufw status numbered

Delete Rule

If I want to delete the SSH rule for V6 IP addresses, I would use the following command.

sudo ufw delete 2

Where 2 is the number in the numbered list from the previous step.

Running the status command again, we can see that rule 2 has infact been removed.

Reset Default Rules

You can’t really reset the default policy without impacting every other rule you’ve established. But you can change the default policy after the fact. Below is the default policy - which you can run at any time.

sudo ufw default allow outgoing
sudo ufw default deny incoming

Reset Everything

If you need to start over, the following command will reset the default policy back to it’s default (same as what I have mentioned above), and remove every other rule you’ve added.

sudo ufw reset

And then if you check the status, you’ll see that you’re back at the start again