UFW Firewall Quick Start Guide

26-01-2024 02:36:55

UFW (Uncomplicated Firewall) is the default firewall software for Ubuntu. This quick start guide lists some common commands for UFW, enabling system administrators to quickly master its usage.

Enabling UFW:

$ sudo ufw enable

Checking UFW Status:

$ sudo ufw status
ufw: command not found

The above result indicates that UFW is not installed.

$ sudo ufw status
Status: inactive

The above result shows that UFW is installed but not configured.

$ sudo ufw status verbose
Status: active

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

The above result indicates that UFW is running.

Disabling UFW:

$ sudo ufw disable

Resetting UFW to its default state:

$ sudo ufw reset

Allowing SSH and disabling other services:

$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing
$ sudo ufw allow ssh
$ sudo ufw enable
$ sudo ufw reload

Allowing port 80 (HTTP) and port 443 (HTTPS), while disabling other ports:

$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing
$ sudo ufw allow 80/tcp
$ sudo ufw allow 443/tcp
$ sudo ufw enable
$ sudo ufw reload

For more information, refer to the official UFW documentation.

http://manpages.ubuntu.com/manpages/cosmic/en/man8/ufw.8.html