ufw
Uncomplicated Firewall management interface
TLDR
SYNOPSIS
ufw [--dry-run] command [rule]
DESCRIPTION
ufw (Uncomplicated Firewall) is a frontend for iptables/nftables designed to make firewall configuration easier. It provides a user-friendly interface for managing netfilter firewall rules while supporting both simple and complex rule specifications.
PARAMETERS
enable
Enable the firewall and load rules on bootdisable
Disable the firewall and unload rulesreload
Reload the firewall configurationreset
Reset to installation defaultsstatus
Show firewall status and rulesstatus verbose
Show detailed status with logging and default policiesstatus numbered
Show rules with line numbers for deletion--dry-run
Show changes without applying them--force
Execute without confirmation prompts
CONFIGURATION
/etc/ufw/ufw.conf
Main configuration file controlling enable/disable state, logging level, and IPv6 support./etc/ufw/before.rules
Custom iptables rules applied before ufw-managed rules./etc/ufw/after.rules
Custom iptables rules applied after ufw-managed rules./etc/default/ufw
Default policy settings and input/output/forward policy configuration.
RULE COMMANDS
allow
Permit matching trafficdeny
Block matching traffic silentlyreject
Block matching traffic and notify senderlimit
Rate-limit connections (blocks after 6+ attempts in 30 seconds)delete
Remove a rule by specification or numberinsert NUM
Add rule at specified positionprepend
Add rule before all others of same IP typeroute allow|deny|reject|limit
Add rule for routed/forwarded traffic
DEFAULT POLICY
default allow|deny|reject incoming
Set default policy for incoming trafficdefault allow|deny|reject outgoing
Set default policy for outgoing trafficdefault allow|deny|reject routed
Set default policy for forwarded traffic
APPLICATION PROFILES
app list
List available application profilesapp info PROFILE
Show information about an application profileapp default allow|deny|reject|skip
Set default application policy
REPORTS
show raw
Show raw iptables rulesshow added
Show rules as they were added on the command lineshow listening
Show listening ports and associated rulesshow builtins
Show default built-in rules
RULE SYNTAX
Simple: ufw allow 22/tcpWith comment: ufw allow 80 comment 'HTTP'Port range: ufw allow 6000:6007/tcpMultiple ports: ufw allow 80,443/tcpFrom address: ufw allow from 192.168.1.0/24Full syntax: ufw allow proto tcp from any to any port 80
LOGGING
logging off
Disable logginglogging on
Enable logging (low level)logging low|medium|high|full
Set logging verbosity level
CAVEATS
Default policies are deny incoming, allow outgoing, deny forwarding. Enabling ufw may disrupt existing connections if rules are not configured first. Use --dry-run to preview changes before applying.
HISTORY
ufw was developed by Canonical for Ubuntu to simplify iptables firewall management. It was first released in Ubuntu 8.04 (2008) and has become a popular firewall tool across many Linux distributions.
SEE ALSO
iptables(8), ip6tables(8), nft(8), firewall-cmd(1)
