All guides
Term

UFW

A command-line interface for managing Netfilter firewall rules, designed to simplify network security configuration in Linux environments.

UFW (Uncomplicated Firewall) is a command-line interface for managing Netfilter firewall rules, designed to simplify network security configuration in Linux environments. Acting as a user-friendly frontend for iptables and nftables backends, it replaces complex packet-filtering syntax with straightforward, human-readable commands. Its primary goal is to make host-based firewall management accessible without sacrificing robust security controls.

How it works

Linux kernels include Netfilter, a framework that inspects, modifies, or drops network packets before they reach running applications. Configuring Netfilter directly requires writing detailed rulesets, which is error-prone during routine administration. UFW translates simple commands into low-level kernel packet-filtering rules across both IPv4 and IPv6 protocols simultaneously.

By default, UFW applies a restrictive security posture: it denies all incoming connections while allowing all outgoing traffic. Administrators then define explicit exceptions based on destination ports, transport protocols, source IP addresses, or specific network interfaces. UFW also integrates application profiles stored in /etc/ufw/applications.d/, allowing software packages like web servers or mail agents to register their required port combinations under a single named service.

Example

Securing a newly provisioned Linux cloud server typically involves permitting remote administration and web traffic before activating the firewall. A standard configuration sequence looks like this:

ufw default deny incoming
ufw default allow outgoing
ufw limit ssh
ufw allow 'Nginx Full'
ufw enable

In this setup, ufw limit ssh protects port 22 by automatically dropping connections from any IP address that attempts to initiate six or more connections within 30 seconds, slowing down automated brute-force scanners. The 'Nginx Full' profile opens ports 80 (HTTP) and 443 (HTTPS) together. Running ufw enable loads the rules into the kernel immediately without a reboot and configures the firewall to persist across system restarts. For step-by-step hardening workflows, see our UFW Firewall Setup Guide: Hard-Won Data for VPS Security.

What matters when choosing a server or hosting

When evaluating a virtual private server (VPS) or dedicated host, verify how the provider handles network filtering alongside local firewalls:

  • Kernel and container support: Full-virtualization KVM instances allow unrestricted Netfilter manipulation, whereas older container-based VPS platforms may restrict kernel modules required by UFW.
  • Cloud provider firewalls: Many cloud platforms offer external security groups at the hypervisor level. Using both an external cloud firewall and UFW provides defense-in-depth, though rules must stay synchronized so traffic is not unintentionally blocked at one layer.
  • IPv6 readiness: Ensure IPv6 filtering is enabled in /etc/default/ufw if your host assigns public IPv6 addresses, preventing unguarded dual-stack exposure.

Common mistakes

  • Enabling UFW before allowing SSH: Activating the firewall prior to adding an SSH exception immediately severs your remote terminal session and locks you out of the server.
  • Assuming Docker respects UFW rules: Docker modifies iptables chains directly, which bypasses standard UFW input rules and can expose container ports publicly even when UFW is set to deny incoming traffic.
  • Overlooking rule order: UFW evaluates rules sequentially from top to bottom. Placing a broad deny rule above a specific allow rule prevents the allow rule from ever matching.

You can review rule ordering and Docker workarounds in our Firewall UFW Configuration Guide: Hard-Won Data for Admins.

FAQ

Does UFW consume significant CPU or memory?

No. UFW itself is only a configuration tool that exits after writing rules; the actual packet filtering happens inside the Linux kernel via Netfilter with negligible resource overhead.

Can UFW run alongside firewalld or raw iptables scripts?

Running multiple firewall management tools simultaneously is strongly discouraged because they overwrite each other's kernel chains, leading to unpredictable network drops.

How do I check active UFW rules without disrupting traffic?

Run ufw status numbered to inspect all active rules, their target actions, and their evaluation order without altering live connections.

All glossary terms

Glossary

Related terms

Full glossary

New guides every week.

A digest of the best pieces on servers, VPN and self-hosted software. No ads, no spam.

1 email a weekOne-click unsubscribeRU · EN
Only slipjar.app articles, nothing else.