ufw

Uncomplicated firewall CLI tool

The ufw CLI-tool is the default Firewall configuration tool for Ubuntu. “ufw” stands for “uncomplicated firewall”. It makes it easy to control what ports of your machine are open and can accept connections from the outside.

Basic usage

To enable ufw (on Ubuntu it’s disabled by default), run sudo ufw enable. This will enable a default set of rules that you can then modify to meet your needs. Check that ufw started correctly with sudo ufw status verbose.

Opening ports

The command structure for allowing incoming connections of certain types on certain ports is as follows:

sudo ufw [allow]/[deny] <port>/<optional: protocol>

using allow or deny depending on whether you want to create or remove the rule, respectively.

Showing rules

As mentioned above, you can check the ufw rule status with

sudo ufw status [verbose]

where verbose is optional. This will list all of the applied rules, showing what types of connections are allowed from what IP ranges to which local ports.