Use it to manage a host firewall on Ubuntu, or when UFW rules seem not to apply.
UFW
UFW (Uncomplicated Firewall) is Ubuntu's simple front end for netfilter: default policies plus allow/deny rules by port, service profile and source.
1. ufw status verbose — active, defaults?
2. ufw status numbered — rule order.
3. Allow: ufw allow from <net> to any port 22 proto tcp.
4. Docker-published ports bypassing UFW? Check iptables -S DOCKER-USER.
5. Test from another host.
ufw rules → rendered into netfilter chains → packet matched in order → default policy if none
For Firewall → UFW, continue with the first unproven Topic check: Inspect UFW status verbose/numbered, default incoming/outgoing/routed policies and the exact rule/profile for the flow. If that boundary is healthy, advance to the adjacent check: Check /etc/ufw before/after/user rule sources and identify generated backend rules when ordering or hidden policy matters. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
UFW config/profile/defaults → UFW rule generation → backend netfilter chains → packet match/verdict → route/socket → application workload
Healthy evidence: UFW defaults and ordered rules match intent, generated backend policy is present, packet evidence shows the expected verdict, and the target service behaves correctly.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Inspect UFW status verbose/numbered, default incoming/outgoing/routed policies and the exact rule/profile for the flow.
- Check
/etc/ufwbefore/after/user rule sources and identify generated backend rules when ordering or hidden policy matters. - Reproduce with counters/logging/capture and verify whether the packet is local INPUT/OUTPUT or routed FORWARD traffic.
- Apply the minimal persistent UFW change, reload cautiously, read back policy and repeat the original plus negative regression tests.
Verification chain. UFW config/profile/defaults → UFW rule generation → backend netfilter chains → packet match/verdict → route/socket → application workload
Step 3 Commands Verify boundary
ufw status verbose
ufw allow 22/tcp
ufw enable
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: a visible allow rule is shadowed by before/after policy, routed traffic hits a different default, IPv6 behavior differs, backend manual edits conflict, or service reachability is blamed on UFW without packet evidence.
Step 5 Common mistakes Narrow the fault
- Enabling UFW without allowing SSH first.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Allow SSH before ufw enable. Rules are evaluated in order — ufw status numbered shows it. Docker publishes ports through its own iptables rules that bypass UFW's INPUT rules.
nft list ruleset— all nftables rulesiptables -S; iptables -t nat -S— iptables rules (if used)firewall-cmd --list-all— firewalld zone settingsufw status verbose— UFW rules and defaultsss -tulpn— which services listen
ReferenceWhat it is1 section · depth on demand
Core model
Treat UFW configuration, UFW status and generated effective rules as three different evidence layers. Confirm enablement, defaults, ordered user rules, application profiles and route/forward settings, then inspect the generated backend rules for the original tuple when behavior differs from the high-level view.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
UFW evidence is resolved when high-level UFW intent is shown to generate the expected effective backend rule path for the original packet and the workload result matches policy; status output alone is insufficient.
nftables/iptables/netfilter own effective kernel enforcement; services own listening/application state.
In depth
ufw: a simple host firewall
ufw ("uncomplicated firewall") is Ubuntu's front end for netfilter. The ufw(8) manual page describes its behaviour:
- The defaults deny incoming and forwarded traffic, and allow outgoing traffic.
- Rules use
allow,deny(drop silently),reject(answer the sender) andlimit. limitallows connections, but denies an address that opens 6 or more connections within 30 seconds.- Rules can be simple (
ufw allow 22/tcp) or complete (ufw allow proto tcp from 10.99.0.0/24 to any port 22). status numberedshows positions for deleting, andinsert Nplaces a rule at a position.- Application profiles from
/etc/ufw/applications.dare listed withufw app list. - Routed traffic needs
ufw routerules, and forwarding enabled in/etc/ufw/sysctl.conf. - Enabling over SSH asks for confirmation. Allow SSH first.
Typical server setup
| Step | Command |
|---|---|
| Defaults | ufw default deny incoming, ufw default allow outgoing |
| SSH from management networks only | ufw allow proto tcp from 10.99.0.0/24 to any port 22 |
| Web | ufw allow 80,443/tcp or ufw allow "Nginx Full" |
| Brute-force protection on a public SSH port | ufw limit 22/tcp |
| Enable | ufw enable |
| Check | ufw status verbose |
Logging levels (manual)
The levels are off, low (the default), medium, high and full. The manual warns that high levels can fill disks quickly. Blocked packets appear in the kernel log with the prefix [UFW BLOCK].
host$ sudo ufw default deny incoming && sudo ufw default allow outgoing
host$ sudo ufw allow proto tcp from 10.99.0.0/24 to any port 22 comment 'mgmt ssh'
host$ sudo ufw allow "Nginx Full"
host$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
host$ sudo ufw status numbered
To Action From
-- ------ ----
[ 1] 22/tcp ALLOW IN 10.99.0.0/24 # mgmt ssh
[ 2] Nginx Full ALLOW IN Anywhere
[ 3] Nginx Full (v6) ALLOW IN Anywhere (v6)
host$ sudo ufw delete 2
host$ sudo journalctl -k -g "UFW BLOCK" -n 3
host$ sudo ufw show raw | head
ufw and Docker
Docker publishes container ports with its own NAT rules, which take effect before ufw's input rules. A port published with -p 8080:80 can therefore be reachable from anywhere, even though ufw denies it. Bind published ports to specific addresses (-p 127.0.0.1:8080:80), or add rules to the DOCKER-USER chain.
Documented example, not captured output.
How it works at runtime
UFW is part of Firewall → UFW. UFW (Uncomplicated Firewall) is a policy frontend that simplifies host firewall management while generating lower-level netfilter rules, including user, before/after and routed policy that may be implemented through nftables/iptables compatibility on the distribution.
nftables, iptables compatibility layers, firewalld and UFW are policy/configuration interfaces that can program overlapping kernel rulesets.
Topic-specific state model. UFW (Uncomplicated Firewall) is a policy frontend that simplifies host firewall management while generating lower-level netfilter rules, including user, before/after and routed policy that may be implemented through nftables/iptables compatibility on the distribution.
Interpretation rule. - ufw status active ≠ every intended backend rule is effective in the packet namespace/path.
- Allow rule shown by UFW ≠ earlier before/after policy or routing/forwarding permits the whole flow.
- Opening a service profile ≠ the process listens on the expected address/port.
- Manual backend edits ≠ persistent UFW policy and may be replaced on reload.
Quick reference
UFW (Uncomplicated Firewall) on Ubuntu:
ufw default deny incoming; ufw default allow outgoing
ufw allow from 10.0.0.0/8 to any port 22 proto tcp
ufw allow 443/tcp
ufw limit ssh # basic rate limiting
ufw enable
ufw status numbered; ufw delete 3
ufw app list
UFW manages INPUT rules; Docker-published ports bypass them because Docker inserts its own NAT/FORWARD rules (use ufw-docker approaches or bind ports to 127.0.0.1). Rules live in /etc/ufw/user.rules.
Limits and how it fails
Primary failure point. UFW evidence is resolved when high-level UFW intent is shown to generate the expected effective backend rule path for the original packet and the workload result matches policy; status output alone is insufficient.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Configuration intent and lifecycle. Choose one authoritative policy manager and understand generated rules before mixing direct nft/iptables edits with firewalld/UFW.
Distribution/platform context. UFW owns its high-level policy, profiles and generated rule ordering. nftables/iptables/netfilter own effective kernel enforcement; services own listening/application state.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Firewall → UFW. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://wiki.nftables.org/wiki-nftables/index.php/Main_Page · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
UFW operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for UFW.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | UFW (Uncomplicated Firewall) is a policy frontend that simplifies host firewall management while generating lower-level netfilter rules, including user, before/after and routed policy that may be implemented through nftables/iptables compatibility on the distribution. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin exact namespace + five-tuple + interfaces/direction → prove route/listener prerequisites → identify manager/backend → snapshot full ruleset + hook priorities/default policies → reproduce with counters/trace + packet capture → correlate conntrack/NAT → change one demonstrated cause → read back effective state → repeat original workload + negative regression flow. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | UFW config/profile/defaults → UFW rule generation → backend netfilter chains → packet match/verdict → route/socket → application workload | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | UFW proof closes when high-level UFW intent is shown to generate the expected effective backend rule path for the original packet and the workload result matches policy; status output alone is insufficient. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux firewall evidence can establish this proof path: UFW config/profile/defaults → UFW rule generation → backend netfilter chains → packet match/verdict → route/socket → application workload | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured namespace, family, five-tuple, interface/direction, manager/backend, ruleset generation, conntrack/NAT state, time window or application scope. UFW proof closes when high-level UFW intent is shown to generate the expected effective backend rule path for the original packet and the workload result matches policy; status output alone is insufficient. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven firewall boundary: preserve the current ruleset/state, capture the exact packet path and rule verdict, change only the demonstrated cause through the authoritative manager, read back effective policy, then repeat the original workload and regression flows. | Continue to the next unresolved boundary while preserving the original test condition. |
UFW · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | UFW |
|---|---|
| Topic path | Firewall → UFW |
| Runtime state | UFW (Uncomplicated Firewall) is a policy frontend that simplifies host firewall management while generating lower-level netfilter rules, including user, before/after and routed policy that may be implemented through nftables/iptables compatibility on the distribution. |
| Fast checks | - Inspect UFW status verbose/numbered, default incoming/outgoing/routed policies and the exact rule/profile for the flow. - Check /etc/ufw before/after/user rule sources and identify generated backend rules when ordering or hidden policy matters. - Reproduce with counters/logging/capture and verify whether the packet is local INPUT/OUTPUT or routed FORWARD traffic. - Apply the minimal persistent UFW change, reload cautiously, read back policy and repeat the original plus negative regression tests. |
| Verification chain | UFW config/profile/defaults → UFW rule generation → backend netfilter chains → packet match/verdict → route/socket → application workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | UFW proof closes when high-level UFW intent is shown to generate the expected effective backend rule path for the original packet and the workload result matches policy; status output alone is insufficient. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |