Objective
The objective is to show how to remove UFW firewall rules selectively on Ubuntu 18.04 Bionic Beaver Linux
Operating System and Software Versions
- Operating System: – Ubuntu 18.04 Bionic Beaver
Requirements
Privileged access to to your Ubuntu 18.04 Bionic Beaver installation will be required.
Conventions
- # – requires given linux commands to be executed with root privileges either directly as a root user or by use of
sudo
command - $ – requires given linux commands to be executed as a regular non-privileged user
Other Versions of this Tutorial
Instructions
List Existing firewall rules
The following linux command will list all currently used firewall rules. Example:
$ sudo ufw status numbered Status: active To Action From -- ------ ---- [ 1] Apache Full ALLOW IN Anywhere [ 2] OpenSSH ALLOW IN Anywhere [ 3] Apache Full (v6) ALLOW IN Anywhere (v6) [ 4] OpenSSH (v6) ALLOW IN Anywhere (v6)
Remove Firewall Rule
Each firewall rule is numbered from 1 to N. Using a relevant firewall rule number we can selectively remove any given rule. For example:
$ sudo ufw delete 3 Deleting: allow 'Apache Full' Proceed with operation (y|n)? y Rule deleted (v6)
The above command will remove firewall rule number 3. Please note, you can only remove one rule at the time. The rule numbering will change every time you make a change:
$ sudo ufw status numbered Status: active To Action From -- ------ ---- [ 1] Apache Full ALLOW IN Anywhere [ 2] OpenSSH ALLOW IN Anywhere [ 3] OpenSSH (v6) ALLOW IN Anywhere (v6)