Languages
[Edit]
EN

ufw - delete firewall rule

6 points
Created by:
Nataniel-Barclay
499

In this short article, we would like to show how to delete rules using ufw command.

Quick solution:

sudo ufw delete [rule_number]


# e.g.
#   sudo ufw delete 1
#   sudo ufw delete 2
#   etc.

Where: [rule_number] should be replaced with rule number (use sudo ufw status numbered command to display rule numbers).

 

Solution 1

Using this approach we need to construct rule.

Template:

sudo ufw delete [rule_query]

Example:

sudo ufw delete allow www

Where: command used to add rule is sudo ufw allow www.

 

Solution 2

Using this approach we need to know rule number.

Simple steps:

  1. display rules using:
    sudo ufw status numbered
    Example output:
    Status: active
    
         To                         Action      From
         --                         ------      ----
    [ 1] 22/tcp                     ALLOW IN    Anywhere
    [ 2] 80/tcp                     ALLOW IN    Anywhere
    [ 3] 443/tcp                    ALLOW IN    Anywhere
     
  2. disable choosen rule using:
    sudo ufw delete 2
    Where: 2 means rule number chosen from 1-3 positions.
     
  3. check changes using:
    sudo ufw status numbered
    Example output:
    Status: active
    
         To                         Action      From
         --                         ------      ----
    [ 1] 22/tcp                     ALLOW IN    Anywhere
    [ 2] 443/tcp                    ALLOW IN    Anywhere

Alternative titles

  1. ufw - remove firewall rule
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join