NAT (Network Address Translation)
Cheat sheet · https://pcornel.dk/topic.php?topic=3535
Answer
NAT in virtual networking lets VMs on a private network share the host's or a virtual router's IP address to reach other networks, and can publish a VM service through port forwarding. It is the default network mode in many desktop hypervisors and libvirt.
Remember
- NAT is stateful translation, not a substitute for valid routing and return-path reachability.
- A translation entry proves matching traffic reached the NAT function, not that the remote endpoint responded.
- Inbound publishing/port forwarding requires a separate destination translation and policy path.
- NAT can mask overlapping/private addresses but adds another troubleshooting boundary.
First checks
virsh net-dumpxml default— libvirt NAT networkiptables -t nat -L -n -v— NAT rulesGet-NetNat— Windows NAT (Hyper-V internal)
Commands
virsh net-list
Verify in this order
VM → NAT network → masquerade → host uplink
Where it usually breaks
First mismatch in guest NIC → virtual switch/bridge → VLAN/port group/security policy → physical uplink → routed path → peer/workload; preserve identity/native error/pre-state before mutation.
Virtual Networking → NAT reference map
| Boundary | Meaning | Evidence limit |
|---|---|---|
| Pre-NAT | Guest identity | Original flow |
| Translation | Mapped address/port | State evidence |
| Post-NAT | External identity | Egress evidence |
| Reverse | Return translation | Required for session |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3535