Use it on systems or scripts still using iptables, or when reading older rule sets.
iptables
iptables is the classic tool for netfilter rules, with tables (filter, nat, mangle) and chains (INPUT, FORWARD, OUTPUT …). On current distributions iptables is usually iptables-nft, which writes nftables rules.
1. iptables -V — nf_tables or legacy?
2. iptables -L INPUT -n -v --line-numbers — rule order and counters.
3. Earlier DROP/REJECT matching first?
4. Insert at the right position: iptables -I INPUT <n> ….
5. Persist: iptables-save > /etc/iptables/rules.v4 (Debian).
packet → table and chain → rules top to bottom → first match target → policy if none
For Firewall → iptables, continue with the first unproven Topic check: Record iptables -V/alternatives backend and inspect IPv4/IPv6 policy rather than assuming legacy versus nft compatibility. If that boundary is healthy, advance to the adjacent check: List relevant tables/chains with numeric output, verbose counters and line numbers; follow every jump in order for the original tuple. 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
manager/rules source → iptables frontend/backend → table/chain order → match/extensions/conntrack → target verdict/NAT → next kernel boundary → workload
Healthy evidence: the active backend is known, ordered chain traversal and counters show the intended match/verdict for both address families in scope, and the workload reflects that policy.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Record iptables -V/alternatives backend and inspect IPv4/IPv6 policy rather than assuming legacy versus nft compatibility.
- List relevant tables/chains with numeric output, verbose counters and line numbers; follow every jump in order for the original tuple.
- Correlate conntrack state, NAT table behavior and packet capture with counters while reproducing the failure.
- Make persistent changes through the authoritative manager where applicable, then read back after reload/reboot risk and repeat positive and negative workload tests.
Verification chain. manager/rules source → iptables frontend/backend → table/chain order → match/extensions/conntrack → target verdict/NAT → next kernel boundary → workload
Step 3 Commands Verify boundary
iptables -S
iptables -L -n -v --line-numbers
iptables-save > rules.v4
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: legacy and nft views are mixed, an earlier rule shadows the intended rule, IPv6 is forgotten, manager reload removes manual changes, or ACCEPT is mistaken for complete connectivity evidence.
It does not show behavior outside the captured namespace, family, five-tuple, interface/direction, manager/backend, ruleset generation, conntrack/NAT state, time window or application scope. iptables is verified only when backend identity, actual ordered rule path and packet counters for the original flow are known and the effective verdict is correlated with end-to-end behavior.
Step 5 Common mistakes Narrow the fault
- Rules not persisted across reboot.
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.
Rules are evaluated top to bottom; the first terminating match wins. iptables -L -n -v --line-numbers shows counters. Save and restore with iptables-save/iptables-restore (or the distribution's persistence package). Do not mix iptables-legacy and nft 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
Identify iptables-nft versus iptables-legacy first, then inspect the relevant IPv4/IPv6 tables and ordered chains with counters and exact matches. Track jumps, state/conntrack modules, policy verdicts and NAT separately, and verify whether another manager such as UFW/firewalld owns the generated rules.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
iptables is verified only when backend identity, actual ordered rule path and packet counters for the original flow are known and the effective verdict is correlated with end-to-end behavior.
In depth
iptables: tables, chains and rule order
iptables organises rules into tables, each with built-in chains. The iptables(8) manual page lists them:
| Table | Built-in chains | Purpose |
|---|---|---|
| filter (default) | INPUT, FORWARD, OUTPUT | Allow or drop |
| nat | PREROUTING, INPUT, OUTPUT, POSTROUTING | Address translation |
| mangle | PREROUTING, INPUT, FORWARD, OUTPUT, POSTROUTING | Change packets or marks |
| raw | PREROUTING, OUTPUT | Exempt from connection tracking (NOTRACK) |
| security | INPUT, FORWARD, OUTPUT | SECMARK labelling for MAC systems |
The manual also defines how rules behave:
- Rules are checked in order, and the first match decides.
- Targets are ACCEPT, DROP, RETURN, or a jump to a user-defined chain.
- Only built-in chains have a policy, which
-Psets to ACCEPT or DROP. iptables-saveandiptables-restoreexport and reload the whole ruleset.
Commands (manual)
| Command | Purpose |
|---|---|
-A chain / -I chain [n] | Append / insert (at the top by default) |
-D chain n / -R chain n | Delete / replace a rule |
-L -n -v --line-numbers | List numerically, with counters and positions |
-S | Print the rules as commands |
-F / -Z | Flush rules / zero counters |
-N / -X | Create / delete a user-defined chain |
-P chain ACCEPT|DROP | Set the policy |
Order matters
-A puts a rule last. If the chain already ends with a catch-all DROP, an appended ACCEPT is never reached. Use -I with a position, and check the order with --line-numbers.
iptables-nft and legacy
On current distributions, iptables is usually iptables-nft. It accepts the old syntax but creates nftables rules. Rules from iptables-legacy live in a separate kernel subsystem. Having both active at once is confusing.
host$ sudo iptables -L INPUT -n -v --line-numbers
Chain INPUT (policy DROP 1203 packets, 72180 bytes)
num pkts bytes target prot opt in out source destination
1 812K 611M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
2 412 24720 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
3 1180 70800 ACCEPT tcp -- * * 10.99.0.0/24 0.0.0.0/0 tcp dpt:22
4 0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
5 0 0 ACCEPT tcp -- * * 10.30.0.0/24 0.0.0.0/0 tcp dpt:3306
host$ sudo iptables -D INPUT 5 && sudo iptables -I INPUT 4 -s 10.30.0.0/24 -p tcp --dport 3306 -j ACCEPT
host$ sudo iptables-save > /etc/iptables/rules.v4
host$ sudo iptables-restore --test < /etc/iptables/rules.v4
Reading the counters
Rule 5 has zero packets, because rule 4 drops all MySQL traffic first. Moving the ACCEPT above the DROP fixes it, as the next command does. Counters (-v) are the quickest way to see which rules actually match.
Documented example, not captured output.
How it works at runtime
iptables is part of Firewall → iptables. iptables is the classic netfilter rule interface organized around tables and built-in chains; modern distributions may implement the command through the nftables backend (iptables-nft) while others still expose legacy xtables semantics, so backend identity is part of every diagnosis.
nftables, iptables compatibility layers, firewalld and UFW are policy/configuration interfaces that can program overlapping kernel rulesets.
Topic-specific state model. iptables is the classic netfilter rule interface organized around tables and built-in chains; modern distributions may implement the command through the nftables backend (iptables-nft) while others still expose legacy xtables semantics, so backend identity is part of every diagnosis.
Interpretation rule. - iptables command exists ≠ legacy iptables backend is active; it may program nftables compatibility rules.
- Rule appended successfully ≠ it is reached; earlier rules or chain policy can decide the packet first.
- iptables IPv4 policy ≠ IPv6 policy; ip6tables or nft inet rules may differ.
- ACCEPT in filter table ≠ NAT/routing/application success and ≠ absence of filtering in another hook/manager.
Quick reference
iptables (legacy syntax, today usually translated to nftables):
iptables -L -n -v --line-numbers
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -s 10.0.0.0/8 -j ACCEPT
iptables -P INPUT DROP
iptables-save > /etc/iptables/rules.v4 # persistence (iptables-persistent / iptables-services)
iptables-restore < /etc/iptables/rules.v4
iptables-translate -A INPUT -p tcp --dport 443 -j ACCEPT # show nft equivalent
Rules are evaluated top-down; the first match with a terminating target wins. Set default DROP only after allowing your management access.
Limits and how it fails
Primary failure point. iptables is verified only when backend identity, actual ordered rule path and packet counters for the original flow are known and the effective verdict is correlated with end-to-end behavior.
A DROP symptom can come from remote firewalls or security groups outside the host. iptables output may represent an nft backend rather than a separate legacy ruleset.
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.
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 → iptables. 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
iptables operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for iptables.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | iptables is the classic netfilter rule interface organized around tables and built-in chains; modern distributions may implement the command through the nftables backend (iptables-nft) while others still expose legacy xtables semantics, so backend identity is part of every diagnosis. | 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 | manager/rules source → iptables frontend/backend → table/chain order → match/extensions/conntrack → target verdict/NAT → next kernel boundary → workload | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | iptables is verified only when backend identity, actual ordered rule path and packet counters for the original flow are known and the effective verdict is correlated with end-to-end behavior. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux firewall evidence can establish this proof path: manager/rules source → iptables frontend/backend → table/chain order → match/extensions/conntrack → target verdict/NAT → next kernel boundary → 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. iptables is verified only when backend identity, actual ordered rule path and packet counters for the original flow are known and the effective verdict is correlated with end-to-end behavior. | 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. |
iptables · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | iptables |
|---|---|
| Topic path | Firewall → iptables |
| Runtime state | iptables is the classic netfilter rule interface organized around tables and built-in chains; modern distributions may implement the command through the nftables backend (iptables-nft) while others still expose legacy xtables semantics, so backend identity is part of every diagnosis. |
| Fast checks | - Record iptables -V/alternatives backend and inspect IPv4/IPv6 policy rather than assuming legacy versus nft compatibility. - List relevant tables/chains with numeric output, verbose counters and line numbers; follow every jump in order for the original tuple. - Correlate conntrack state, NAT table behavior and packet capture with counters while reproducing the failure. - Make persistent changes through the authoritative manager where applicable, then read back after reload/reboot risk and repeat positive and negative workload tests. |
| Verification chain | manager/rules source → iptables frontend/backend → table/chain order → match/extensions/conntrack → target verdict/NAT → next kernel boundary → 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 | iptables is verified only when backend identity, actual ordered rule path and packet counters for the original flow are known and the effective verdict is correlated with end-to-end behavior. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |