How do I revert a ufw command? [closed]
Asked Answered
C

1

12

sudo ufw status on my Debian server initially showed the following configuration:

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)

I've been able to successfully allow http connections via sudo ufw allow http which yielded the following:

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
80                         ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
80                         ALLOW       Anywhere (v6)

What is the command to reverse this? I've tried sudo ufw deny http, but now sudo ufw status is different than originally (it now explicitly lists that http is denied):

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
80                         DENY        Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
80                         DENY        Anywhere (v6)

Is this the same as my initial config, or is there a different command to revert sudo ufw allow http?

Conchoidal answered 3/6, 2016 at 17:30 Comment(0)
L
17

From ufw's man page, it supports a "delete" command

   delete RULE|NUM
          deletes the corresponding RULE

They also give an example:

   To delete a rule, simply prefix the original rule with delete with or without the rule comment. For example, if the original rule was:

     ufw deny 80/tcp

   Use this to delete it:

     ufw delete deny 80/tcp

   You may also specify the rule by NUM, as seen in the status numbered output. For example, if you want to delete rule number '3', use:

     ufw delete 3
Lyophobic answered 3/6, 2016 at 17:41 Comment(2)
Thanks! I specifically needed sudo ufw delete allow http and worked as desired.Conchoidal
Awesome. A great way to get help directly from your linux box is typing "man" (for manual) followed by the command you need help on. Especially the popular commands have very detailed information in their manual, along with examples. This can work with files too (provided they have a manual entry - typing "man shadow" will explain the shadow-file, where all the passwords are stored, to you). :)Lyophobic

© 2022 - 2024 — McMap. All rights reserved.