Pcornel
Linux · Linux Firewall

FORWARD

Cheat sheet · https://pcornel.dk/topic.php?topic=2816

Back to the Topic

Answer

The FORWARD chain filters packets routed through the host between interfaces — on routers, VPN gateways and container/VM hosts. Forwarding must also be enabled with net.ipv4.ip_forward=1.

Remember

Docker and libvirt add their own FORWARD rules; a default-drop FORWARD policy from another tool can break them. Check sysctl net.ipv4.ip_forward first.

First checks

  • nft list ruleset — all nftables rules
  • iptables -S; iptables -t nat -S — iptables rules (if used)
  • firewall-cmd --list-all — firewalld zone settings
  • ufw status verbose — UFW rules and defaults
  • ss -tulpn — which services listen

Commands

nft list ruleset

Verify in this order

packet arrives for another host → ip_forward enabled → forward hook rules → routed out → 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=2816

Confirmation

Confirm action

Continue?