Pcornel
Virtualization · Virtual Networking

NAT (Network Address Translation)

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

Back to the Topic

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 network
  • iptables -t nat -L -n -v — NAT rules
  • Get-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

BoundaryMeaningEvidence limit
Pre-NATGuest identityOriginal flow
TranslationMapped address/portState evidence
Post-NATExternal identityEgress evidence
ReverseReturn translationRequired 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

Confirmation

Confirm action

Continue?