Linux Firewall
Cheat sheet · https://pcornel.dk/topic.php?topic=2809
Answer
A Linux host firewall filters packets in the kernel's netfilter framework. Rules are written with nftables (modern), iptables (legacy, often a front end to nftables) or managed by firewalld (RHEL) or UFW (Ubuntu).
Remember
Use one management tool per host — mixing firewalld, UFW and hand-written rules leads to surprises. Find out which one is active, then read the full ruleset. Allow your SSH session before enabling a default-deny policy.
First checks
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
Commands
sudo nft list ruleset- Full nftables ruleset.
nftnft list rulesetsystemctl is-active firewalld ufw nftablesiptables -Vss -tlnpip natip filter
Verify in this order
packet arrives → netfilter hooks → rules in order → accept/drop → service receives it
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=2809