NAT (Network Address Translation)
Cheat sheet · https://pcornel.dk/topic.php?topic=2817
Answer
NAT on Linux rewrites addresses in netfilter: SNAT/masquerade in POSTROUTING lets internal hosts share the host's address; DNAT in PREROUTING forwards an incoming port to an internal host.
Remember
Masquerade needs ip_forward and a FORWARD rule allowing the traffic. Port forwarding (DNAT) also needs the FORWARD rule and a return route via this host. conntrack -L shows the translations.
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
Verify in this order
packet → PREROUTING (DNAT) → routing → FORWARD → POSTROUTING (SNAT/masquerade) → conntrack reverses replies
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=2817