Introduction and Concepts
What is UFW?
UFW (Uncomplicated Firewall) is a simplified interface for managing iptables rules on Linux. It allows you to control incoming and outgoing network traffic on your server in an intuitive way.
Why Use a Firewall?
┌─────────────────────────────────────────────────────────────────────────────┐
│ WHY A FIREWALL IS ESSENTIAL │
└─────────────────────────────────────────────────────────────────────────────┘
INTERNET
│
┌───────────────────────┼───────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────┐
│ Legitimate│ │ Suspicious│ │ Malicious │
│ Traffic │ │ Traffic │ │ Traffic │
│ (HTTP) │ │ (Scan) │ │ (Attack) │
└─────┬─────┘ └─────┬─────┘ └─────┬─────┘
│ │ │
└──────────────────────┼──────────────────────┘
│
▼
┌────────────────────────┐
│ │
│ 🛡️ UFW FIREWALL │
│ │
│ ┌──────────────────┐ │
│ │ Rule 1: SSH ✓ │ │
│ │ Rule 2: HTTP ✓ │ │
│ │ Rule 3: HTTPS ✓ │ │
│ │ Default: DENY ✗ │ │
│ └──────────────────┘ │
│ │
└───────────┬────────────┘
│
┌────────────────┼────────────────┐
│ │ │
▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐
│ ✓ │ │ ✗ │ │ ✗ │
│Accepted│ │Blocked │ │Blocked │
└────────┘ └────────┘ └────────┘
Firewall Architecture
UFW Position in the Network Stack
┌─────────────────────────────────────────────────────────────────────────────┐
│ UFW / IPTABLES / NETFILTER ARCHITECTURE │
└─────────────────────────────────────────────────────────────────────────────┘
APPLICATIONS (Layer 7)
──────────────────────
│
│ ┌─────────────────────────────────────────────────────┐
│ │ USER SPACE │
│ │ │
│ │ ┌─────────────────────────────────────────┐ │
│ │ │ UFW (Frontend) │ │
│ │ │ │ │
│ │ │ • Simplified interface │ │
│ │ │ • Intuitive commands │ │
│ │ │ • Profile management │ │
│ │ └──────────────────┬──────────────────────┘ │
│ │ │ │
│ │ ▼ │
│ │ ┌─────────────────────────────────────────┐ │
│ │ │ IPTABLES (Backend) │ │
│ │ │ │ │
│ │ │ • Tables: filter, nat, mangle │ │
│ │ │ • Chains: INPUT, OUTPUT, FORWARD │ │
│ │ │ • Detailed rules │ │
│ │ └──────────────────┬──────────────────────┘ │
│ │ │ │
│ └───────────────────────┼─────────────────────────────┘
│ │
│ ════════════════════════╪════════════════════════════════
│ │
│ ┌───────────────────────┼─────────────────────────────┐
│ │ ▼ KERNEL SPACE │
│ │ ┌─────────────────────────────────────────┐ │
│ │ │ NETFILTER (Framework) │ │
│ │ │ │ │
│ │ │ • Hooks in network stack │ │
│ │ │ • Packet-level filtering │ │
│ │ │ • NAT, Connection tracking │ │
│ │ └──────────────────┬──────────────────────┘ │
│ │ │ │
│ └───────────────────────┼─────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────┐
│ NETWORK INTERFACE │
│ (eth0, ens3, etc.) │
└─────────────────────────────────────────────────────────────┘
│
▼
INTERNET
Packet Processing Flow
┌─────────────────────────────────────────────────────────────────────────────┐
│ UFW PROCESSING FLOW │
└─────────────────────────────────────────────────────────────────────────────┘
INCOMING PACKET
│
▼
┌────────────────────────┐
│ INPUT CHAIN │
└───────────┬────────────┘
│
┌─────────────────────┼─────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Rule 1 │ │ Rule 2 │ │ Rule N │
│ SSH (22) │ │ HTTP (80) │ │ Custom │
│ │ │ │ │ │
│ Match? ─────┼──No──▶│ Match? ─────┼──No──▶│ Match? ─────┼──No──┐
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│Yes │Yes │Yes │
▼ ▼ ▼ │
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ ACCEPT │ │ ACCEPT │ │ ACCEPT │ │
└─────────────┘ └─────────────┘ └─────────────┘ │
│
▼
┌─────────────────┐
│ DEFAULT RULE │
│ │
│ deny incoming │
│ │
└────────┬────────┘
│
▼
┌─────────────────┐
│ DROP │
│ (Packet dropped)│
└─────────────────┘
OUTGOING PACKET
│
▼
┌────────────────────────┐
│ OUTPUT CHAIN │
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ DEFAULT RULE │
│ allow outgoing │
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ ACCEPT │
│ (Packet allowed) │
└────────────────────────┘
Prerequisites
System Requirements
┌─────────────────────────────────────────────────────────────────┐
│ SYSTEM PREREQUISITES │
├─────────────────────┬───────────────────────────────────────────┤
│ Element │ Required │
├─────────────────────┼───────────────────────────────────────────┤
│ System │ Ubuntu 18.04+ / Debian 9+ │
│ Access │ root or sudo │
│ Connection │ Active SSH session │
│ Network │ Internet connection │
└─────────────────────┴───────────────────────────────────────────┘
Pre-flight Checks
# Check distribution
cat /etc/os-release
# Check sudo privileges
sudo whoami
# Check current SSH connection
who
# Check server IP
ip addr show
Installation
Installation on Ubuntu/Debian
# Update repositories
sudo apt update
# Install UFW
sudo apt install ufw -y
# Verify installation
which ufw
Check Initial Status
# Check UFW status
sudo ufw status
# Expected output:
# Status: inactive
┌─────────────────────────────────────────────────────────────────────────────┐
│ INSTALLATION PROCESS │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ apt │ │ UFW │ │ Config │ │ UFW │
│ update │────▶│ install │────▶│ Files │────▶│ Ready │
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
│
▼
┌─────────────────────────────────────┐
│ /etc/ufw/ │
│ ├── ufw.conf (config) │
│ ├── before.rules (pre-rules) │
│ ├── after.rules (post-rules) │
│ └── user.rules (your rules) │
└─────────────────────────────────────┘
Basic Configuration
⚠️ CRITICAL WARNING
┌─────────────────────────────────────────────────────────────────────────────┐
│ ⚠️ WARNING - RISK OF ACCESS LOSS │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ALWAYS allow SSH port (22) BEFORE enabling UFW! │
│ │
│ If you enable UFW without allowing SSH, you will be │
│ PERMANENTLY LOCKED OUT of your server. │
│ │
│ Mandatory order: │
│ 1. sudo ufw allow 22/tcp │
│ 2. sudo ufw enable │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
Step 1: Set Default Rules
# Block all incoming traffic by default
sudo ufw default deny incoming
# Allow all outgoing traffic by default
sudo ufw default allow outgoing
┌─────────────────────────────────────────────────────────────────────────────┐
│ DEFAULT RULES │
└─────────────────────────────────────────────────────────────────────────────┘
INCOMING TRAFFIC OUTGOING TRAFFIC
──────────────── ────────────────
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ DENY │ │ ALLOW │
│ (Block) │ │ (Permit) │
└─────────────┘ └─────────────┘
│ │
▼ ▼
┌────────────────────────────────┐ ┌────────────────────────────────┐
│ Only EXPLICITLY allowed │ │ All outgoing connections │
│ connections can pass │ │ are permitted │
│ │ │ │
└────────────────────────────────┘ └────────────────────────────────┘
Step 2: Allow Essential Services
# SSH (MANDATORY - Do this first!)
sudo ufw allow 22/tcp
# HTTP (web server)
sudo ufw allow 80/tcp
# HTTPS (secure web server)
sudo ufw allow 443/tcp
Step 3: Enable UFW
# Enable the firewall
sudo ufw enable
# Message displayed:
# Command may disrupt existing ssh connections. Proceed with operation (y|n)?
# Answer: y
Step 4: Verify Configuration
# Display status and rules
sudo ufw status verbose
┌─────────────────────────────────────────────────────────────────────────────┐
│ EXAMPLE UFW STATUS OUTPUT │
└─────────────────────────────────────────────────────────────────────────────┘
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
22/tcp ALLOW IN Anywhere
80/tcp ALLOW IN Anywhere
443/tcp ALLOW IN Anywhere
22/tcp (v6) ALLOW IN Anywhere (v6)
80/tcp (v6) ALLOW IN Anywhere (v6)
443/tcp (v6) ALLOW IN Anywhere (v6)
Advanced Rules
Command Syntax
┌─────────────────────────────────────────────────────────────────────────────┐
│ UFW RULE SYNTAX │
└─────────────────────────────────────────────────────────────────────────────┘
sudo ufw [allow|deny|reject] [from <source>] [to <dest>] [port <port>] [proto <protocol>]
┌───────────────────────────────────────────────────────────────────────────┐
│ │
│ Syntax examples: │
│ │
│ ufw allow 22 → Allow port 22 (TCP+UDP) │
│ ufw allow 22/tcp → Allow port 22 TCP only │
│ ufw allow from 192.168.1.0/24 → Allow a subnet │
│ ufw deny 3306 → Block port 3306 │
│ ufw allow from 10.0.0.5 to any port 22 → Specific IP to port │
│ │
└───────────────────────────────────────────────────────────────────────────┘
Allow Specific Port
# TCP port
sudo ufw allow 8080/tcp
# UDP port
sudo ufw allow 53/udp
# TCP and UDP port
sudo ufw allow 3478
# Port range
sudo ufw allow 6000:6007/tcp
Allow Specific IP
# Allow all connections from an IP
sudo ufw allow from 192.168.1.100
# Allow an IP to a specific port
sudo ufw allow from 192.168.1.100 to any port 22
# Allow a subnet
sudo ufw allow from 10.0.0.0/8
# Allow a subnet to a specific port
sudo ufw allow from 192.168.1.0/24 to any port 3306
┌─────────────────────────────────────────────────────────────────────────────┐
│ IP-BASED RULES DIAGRAM │
└─────────────────────────────────────────────────────────────────────────────┘
INTERNET
│
┌───────────────────────┼───────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ 192.168.1.100│ │ 10.0.0.50 │ │ Other IPs │
│ (Allowed) │ │ (Allowed) │ │ (Not listed)│
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Port 22 ✓ │ │ Port 3306 ✓ │ │ All ports │
│ Port 80 ✓ │ │ │ │ ✗ │
│ Port 443 ✓ │ │ │ │ │
└─────────────┘ └─────────────┘ └─────────────┘
Block IP or Port
# Block a specific IP
sudo ufw deny from 192.168.1.200
# Block an IP to a port
sudo ufw deny from 192.168.1.200 to any port 22
# Block a port
sudo ufw deny 3306/tcp
# Reject (with notification to sender)
sudo ufw reject 23/tcp
┌─────────────────────────────────────────────────────────────────────────────┐
│ DENY vs REJECT │
└─────────────────────────────────────────────────────────────────────────────┘
DENY (DROP) REJECT
─────────── ──────
┌─────────────┐ ┌─────────────┐
│ Incoming │ │ Incoming │
│ Packet │ │ Packet │
└──────┬──────┘ └──────┬──────┘
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ UFW │ │ UFW │
│ (DENY) │ │ (REJECT) │
└──────┬──────┘ └──────┬──────┘
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ Packet │ │ ICMP │
│ silently │ │ Message │
│ ignored │ │ "refused" │
└─────────────┘ └──────┬──────┘
│
Sender doesn't know ▼
what happened Sender receives
(timeout) notification
Rule Management
List Rules
# Simple status
sudo ufw status
# Status with rule numbers
sudo ufw status numbered
# Detailed status
sudo ufw status verbose
Delete a Rule
# Method 1: By number (recommended)
sudo ufw status numbered
# Then:
sudo ufw delete 3
# Method 2: By exact rule
sudo ufw delete allow 8080/tcp
┌─────────────────────────────────────────────────────────────────────────────┐
│ DELETING RULE BY NUMBER │
└─────────────────────────────────────────────────────────────────────────────┘
$ sudo ufw status numbered
To Action From
-- ------ ----
[ 1] 22/tcp ALLOW IN Anywhere
[ 2] 80/tcp ALLOW IN Anywhere
[ 3] 8080/tcp ALLOW IN Anywhere ◀── To delete
[ 4] 443/tcp ALLOW IN Anywhere
$ sudo ufw delete 3
Deleting:
allow 8080/tcp
Proceed with operation (y|n)? y
Rule deleted
Reset UFW
# Reset all rules (WARNING!)
sudo ufw --force reset
# This will:
# - Disable UFW
# - Delete all rules
# - Reset to default settings
Reload Rules
# Reload configuration
sudo ufw reload
Configuration Examples
Web Server Configuration
┌─────────────────────────────────────────────────────────────────────────────┐
│ WEB SERVER CONFIGURATION │
└─────────────────────────────────────────────────────────────────────────────┘
INTERNET
│
▼
┌────────────────────────┐
│ UFW │
│ │
│ ┌──────────────────┐ │
│ │ Port 22 (SSH) ✓│ │
│ │ Port 80 (HTTP) ✓│ │
│ │ Port 443 (HTTPS)✓│ │
│ │ Other ports ✗│ │
│ └──────────────────┘ │
│ │
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ WEB SERVER │
│ (Nginx/Apache) │
└────────────────────────┘
# Web server configuration
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
Database Server Configuration
┌─────────────────────────────────────────────────────────────────────────────┐
│ DATABASE SERVER CONFIGURATION │
└─────────────────────────────────────────────────────────────────────────────┘
INTERNET
│
┌────────────────────────┼────────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Admin │ │ Web Server │ │ Other IPs │
│192.168.1.100│ │ 10.0.0.0/8 │ │ │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SSH (22) ✓ │ │MySQL (3306)✓│ │ All ports │
│ │ │ │ │ ✗ │
└─────────────┘ └─────────────┘ └─────────────┘
# Database server configuration
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow from 10.0.0.0/8 to any port 3306
sudo ufw enable
Game Server Configuration (Minecraft)
┌─────────────────────────────────────────────────────────────────────────────┐
│ MINECRAFT SERVER CONFIGURATION │
└─────────────────────────────────────────────────────────────────────────────┘
INTERNET
│
▼
┌────────────────────────┐
│ UFW │
│ │
│ ┌──────────────────┐ │
│ │ Port 22 (SSH) ✓│ │
│ │ Port 25565 (MC) ✓│ │
│ │ Other ports ✗│ │
│ └──────────────────┘ │
│ │
└───────────┬────────────┘
│
▼
┌────────────────────────┐
│ MINECRAFT SERVER │
│ (Java/Bedrock) │
└────────────────────────┘
# Minecraft server configuration
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 25565/tcp # Minecraft Java
# sudo ufw allow 19132/udp # Minecraft Bedrock (if needed)
sudo ufw enable
Multi-Service Configuration
┌─────────────────────────────────────────────────────────────────────────────┐
│ MULTI-SERVICE CONFIGURATION │
└─────────────────────────────────────────────────────────────────────────────┘
INTERNET
│
▼
┌──────────────────────────────────────┐
│ UFW │
│ │
│ Open ports: │
│ ┌────────────────────────────────┐ │
│ │ 22/tcp - SSH │ │
│ │ 80/tcp - HTTP │ │
│ │ 443/tcp - HTTPS │ │
│ │ 25/tcp - SMTP │ │
│ │ 587/tcp - Submission │ │
│ │ 993/tcp - IMAPS │ │
│ │ 3306/tcp - MySQL (IP limited) │ │
│ └────────────────────────────────┘ │
│ │
└──────────────────┬───────────────────┘
│
┌────────────────────────┼────────────────────────┐
▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────┐
│ Nginx │ │ Postfix │ │ MySQL │
│ (80, 443) │ │ (25, 587) │ │ (3306) │
└───────────┘ └───────────┘ └───────────┘
# Multi-service configuration
sudo ufw default deny incoming
sudo ufw default allow outgoing
# SSH
sudo ufw allow 22/tcp
# Web
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Mail
sudo ufw allow 25/tcp
sudo ufw allow 587/tcp
sudo ufw allow 993/tcp
# Database (restricted access)
sudo ufw allow from 10.0.0.0/8 to any port 3306
sudo ufw enable
Monitoring and Logs
Enable Logging
# Enable logging
sudo ufw logging on
# Available levels: off, low, medium, high, full
sudo ufw logging medium
View Logs
# Watch logs in real-time
sudo tail -f /var/log/ufw.log
# View last 50 entries
sudo tail -n 50 /var/log/ufw.log
# Search for specific events
sudo grep "BLOCK" /var/log/ufw.log | tail -20
┌─────────────────────────────────────────────────────────────────────────────┐
│ UFW LOG EXAMPLE │
└─────────────────────────────────────────────────────────────────────────────┘
Jan 15 10:23:45 server kernel: [UFW BLOCK] IN=eth0 OUT= MAC=...
SRC=192.168.1.200 DST=10.0.0.5 LEN=60 TOS=0x00 PREC=0x00 TTL=64
ID=12345 DF PROTO=TCP SPT=54321 DPT=3306 WINDOW=65535 RES=0x00 SYN URGP=0
┌─────────────────────────────────────────────────────────────────────┐
│ Decoded: │
│ │
│ [UFW BLOCK] → Action taken (packet blocked) │
│ IN=eth0 → Input interface │
│ SRC=192.168.1.200 → Source IP │
│ DST=10.0.0.5 → Destination IP │
│ PROTO=TCP → Protocol │
│ DPT=3306 → Destination port (MySQL) │
│ SYN → Packet type (connection attempt) │
└─────────────────────────────────────────────────────────────────────┘
Troubleshooting
Locked Out of Server
┌─────────────────────────────────────────────────────────────────────────────┐
│ RECOVERY PROCEDURE │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────┐
│ SSH access blocked? │
└──────────┬──────────┘
│
┌────────────────┴────────────────┐
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ VNC/KVM Console │ │ Contact hosting │
│ available? │ │ provider │
└────────┬────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ Connect via │
│ VNC/KVM │
└────────┬────────┘
│
▼
┌─────────────────┐
│ sudo ufw disable│
└────────┬────────┘
│
▼
┌─────────────────┐
│ Reconfigure │
│ rules properly │
└─────────────────┘
Rules Not Working
# Verify UFW is active
sudo ufw status
# Check rule order
sudo ufw status numbered
# Reload rules
sudo ufw reload
# Check underlying iptables rules
sudo iptables -L -n -v
UFW and Docker
┌─────────────────────────────────────────────────────────────────────────────┐
│ UFW + DOCKER ISSUE │
└─────────────────────────────────────────────────────────────────────────────┘
Docker modifies iptables directly, bypassing UFW!
┌──────────────────┐
│ Docker │
│ (port mapping) │
└────────┬─────────┘
│
│ Modifies directly
▼
┌──────────────────┐
│ iptables │◀──── UFW is not consulted!
│ (DOCKER chain) │
└──────────────────┘
SOLUTION: Disable Docker's iptables management
# Edit Docker configuration
sudo nano /etc/docker/daemon.json
{
"iptables": false
}
# Restart Docker
sudo systemctl restart docker
Diagnostic Commands
# Check active connections
sudo ss -tulpn
# Check iptables rules
sudo iptables -L -n
# Test a specific port
nc -zv localhost 80
# Check listening processes
sudo netstat -tlnp
Best Practices
Security Checklist
┌─────────────────────────────────────────────────────────────────────────────┐
│ UFW BEST PRACTICES CHECKLIST │
└─────────────────────────────────────────────────────────────────────────────┘
✅ ALWAYS allow SSH before enabling UFW
✅ Principle of least privilege: only open necessary ports
✅ Use IP-based rules when possible (more secure)
✅ Enable logging to monitor blocked traffic
✅ Test rules before closing SSH session
✅ Document all added rules
✅ Regularly review rules (remove obsolete ones)
✅ Combine with fail2ban to block brute-force attacks
✅ Use reject for common ports (feedback to attacker)
and deny for others (stealth mode)
✅ Backup configuration before major changes
Recommended Rule Order
┌─────────────────────────────────────────────────────────────────────────────┐
│ RULE ORDER (PRIORITY) │
└─────────────────────────────────────────────────────────────────────────────┘
HIGH PRIORITY
│
▼
┌─────────────────────────────────────────┐
│ 1. Specific DENY rules (blocked IPs) │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ 2. Specific ALLOW rules (IP whitelist) │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ 3. Service rules (open ports) │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ 4. Default rule (deny incoming) │
└─────────────────────────────────────────┘
LOW PRIORITY
Command Reference
┌─────────────────────────────────────────────────────────────────────────────┐
│ UFW COMMAND CHEAT SHEET │
└─────────────────────────────────────────────────────────────────────────────┘
┌───────────────────────────────┬─────────────────────────────────────────────┐
│ Command │ Description │
├───────────────────────────────┼─────────────────────────────────────────────┤
│ sudo ufw status │ Show status │
│ sudo ufw status numbered │ Show with numbers │
│ sudo ufw status verbose │ Show detailed │
├───────────────────────────────┼─────────────────────────────────────────────┤
│ sudo ufw enable │ Enable firewall │
│ sudo ufw disable │ Disable firewall │
│ sudo ufw reload │ Reload rules │
├───────────────────────────────┼─────────────────────────────────────────────┤
│ sudo ufw default deny incoming│ Block incoming by default │
│ sudo ufw default allow outgoing│ Allow outgoing by default │
├───────────────────────────────┼─────────────────────────────────────────────┤
│ sudo ufw allow 22/tcp │ Allow a port │
│ sudo ufw deny 3306/tcp │ Block a port │
│ sudo ufw allow from IP │ Allow an IP │
│ sudo ufw deny from IP │ Block an IP │
├───────────────────────────────┼─────────────────────────────────────────────┤
│ sudo ufw delete 3 │ Delete rule #3 │
│ sudo ufw delete allow 80/tcp │ Delete by rule │
├───────────────────────────────┼─────────────────────────────────────────────┤
│ sudo ufw --force reset │ Reset everything │
│ sudo ufw logging on │ Enable logging │
└───────────────────────────────┴─────────────────────────────────────────────┘
FAQ
Q: Can I use UFW with another firewall? A: No, use only one firewall at a time to avoid conflicts.
Q: Does UFW work with Docker? A: Yes, but requires specific configuration (see Troubleshooting section).
Q: How do I allow multiple ports?
A: Use a range (6000:6007/tcp) or multiple allow commands.
Q: Does UFW work on CentOS/RHEL? A: Yes, but installation differs. Consider using firewalld on these distributions.


















