Skip to main content

UFW (Uncomplicated Firewall)

UFW is a user-friendly frontend for managing iptables firewall rules.

Basic Commands

Check Status

Shows whether the firewall is active and lists the current rules.

sudo ufw status

Enable Firewall

Enables UFW. Warning: Ensure you have allowed SSH before enabling to avoid locking yourself out.

sudo ufw enable

Disable Firewall

Disables UFW.

sudo ufw disable

Managing Rules

Allow a Port/Protocol

Allows incoming traffic on a specific port.

sudo ufw allow <port>

Example: sudo ufw allow 80 or sudo ufw allow 4000/tcp

Allow a Service

Allows traffic based on a service profile.

sudo ufw allow <service_name>

Example: sudo ufw allow OpenSSH or sudo ufw allow "WWW Full"

Deny a Port

Blocks incoming traffic on a specific port.

sudo ufw deny <port>

Example: sudo ufw deny http

Delete a Rule

Deletes an existing rule.

sudo ufw delete allow <port>

Example: sudo ufw delete allow 80