Netfilter
Cheat sheet · https://pcornel.dk/topic.php?topic=2810
Answer
Netfilter is the kernel framework behind Linux firewalls and NAT. Packets pass hooks — prerouting, input, forward, output, postrouting — where tables and chains of rules act on them; conntrack tracks connection state.
Remember
Incoming traffic to the host hits INPUT; routed traffic hits FORWARD; NAT happens in PREROUTING (DNAT) and POSTROUTING (SNAT). Allow ESTABLISHED,RELATED early so replies pass. conntrack -L shows tracked connections.
First checks
conntrack -L— tracked connectionsnft 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
Commands
nft list hooks
Verify in this order
prerouting (DNAT) → routing decision → input or forward → output → postrouting (SNAT)
Where it usually breaks
First mismatch in link/interface → address/namespace → route/neighbor → firewall/policy → socket/daemon → DNS/TLS/SSH/application peer path; preserve identity/native diagnostic/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2810