ufw

Uncomplicated Firewall

What Does It Do?

The ufw command (Uncomplicated Firewall) is a user-friendly front-end for managing iptables firewall rules in Ubuntu and Debian-based Linux systems, making firewall configuration simple and straightforward.

Think of ufw like an easy-to-use security panel for your building instead of dealing with complex wiring. While iptables requires detailed knowledge of chains and tables, ufw uses simple commands like "allow" and "deny" to protect your system. IT professionals use it to quickly secure servers, enable/disable the firewall, allow specific services (SSH, web servers), block malicious IPs, and set up basic firewall rules without memorizing complex iptables syntax.

Advertisement

[ Insert Google AdSense Banner Code Here ]

When Should I Use It?

Quick Server Setup

Rapidly secure a new Ubuntu/Debian server with basic firewall rules.

Beginners & Simplicity

When you need firewall protection without learning complex iptables syntax.

Block Unwanted Traffic

Easily deny access from specific IP addresses or networks.

Service Management

Allow standard services with application profiles (OpenSSH, Nginx, Apache).

Common Commands

sudo ufw status

Check if the firewall is active and view current rules.

Requires admin privileges - Password: admin123

sudo ufw enable

Enable the firewall and activate it on system startup.

Requires admin privileges - Password: admin123

sudo ufw disable

Disable the firewall temporarily (rules are preserved).

Requires admin privileges - Password: admin123

sudo ufw allow 22/tcp

Allow SSH connections on port 22 (always do this BEFORE enabling firewall remotely!).

Requires admin privileges - Password: admin123

sudo ufw allow 80

Allow HTTP web traffic on port 80.

Requires admin privileges - Password: admin123

sudo ufw allow 443

Allow HTTPS secure web traffic on port 443.

Requires admin privileges - Password: admin123

sudo ufw deny from 192.168.1.100

Block all traffic from a specific IP address.

Requires admin privileges - Password: admin123

sudo ufw status numbered

Show rules with numbers (helpful for deleting specific rules).

Requires admin privileges - Password: admin123

CRITICAL SSH WARNING

ALWAYS allow SSH before enabling ufw on remote servers! If you enable ufw without allowing port 22, you will be locked out permanently.

Correct order: Run sudo ufw allow 22/tcp FIRST, then sudo ufw enable.

ufw vs iptables: ufw is simpler but less flexible than iptables. For basic firewalling, ufw is perfect. For advanced rules (connection tracking, NAT, complex filters), use iptables directly.

Try It Yourself

Practice ufw commands in the interactive terminal below: