ufw
Linux · Network · reference only
What it does
Simple firewall (Uncomplicated Firewall): it allows or blocks traffic with easy-to-read rules, on top of iptables.
Syntax
ufw [opciones] orden
Options and parameters
status [verbose|numbered]Shows whether it is active and the current rules.
enableEnables the firewall and keeps it active at boot.
disableDisables the firewall.
allow reglaAllows traffic, for example 22/tcp or an application name.
deny reglaBlocks traffic.
delete reglaRemoves a rule, by its text or by its number.
default allow|deny incoming|outgoingChanges the default policy.
resetDisables the firewall and deletes all rules.
Usage examples
sudo ufw status verboseShows the status, policies and rules.
sudo ufw allow 22/tcpAllows SSH connections.
sudo ufw deny from 203.0.113.5Blocks all traffic from that address.
sudo ufw enableEnables the firewall.
Notes and common mistakes
- If you manage the machine over SSH, allow port 22 before running enable or you will lose access.
- It is installed with sudo apt install ufw; by default it blocks incoming traffic and allows outgoing.