EN
ufw - delete firewall rule
6
points
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:
- display rules using:
Example output:sudo ufw status numberedStatus: active To Action From -- ------ ---- [ 1] 22/tcp ALLOW IN Anywhere [ 2] 80/tcp ALLOW IN Anywhere [ 3] 443/tcp ALLOW IN Anywhere - disable choosen rule using:
Where:sudo ufw delete 22means rule number chosen from 1-3 positions.
- check changes using:
Example output:sudo ufw status numberedStatus: active To Action From -- ------ ---- [ 1] 22/tcp ALLOW IN Anywhere [ 2] 443/tcp ALLOW IN Anywhere