18.3. Network Address Translation Mode
By default, virtual network switches operate in NAT mode. They use IP masquerading rather than SNAT (Source-NAT) or DNAT (Destination-NAT). IP masquerading enables connected guests to use the host physical machine IP address for communication to any external network. By default, computers that are placed externally to the host physical machine cannot communicate to the guests inside when the virtual network switch is operating in NAT mode, as shown in the following diagram:
![Virtual network switch using NAT with two guests](https://access.redhat.com/webassets/avalon/d/Red_Hat_Enterprise_Linux-6-Virtualization_Administration_Guide-en-US/images/6bc64ce8930123f658b35055f475283b/vn-04-hostwithnatswitch.png)
Figure 18.3. Virtual network switch using NAT with two guests
Warning
Virtual network switches use NAT configured by iptables rules. Editing these rules while the switch is running is not recommended, as incorrect rules may result in the switch being unable to communicate.
If the switch is not running, you can set th public IP range for forward mode NAT in order to create a port masquerading range by running:
# iptables -j SNAT --to-source [start]-[end]
18.3.1. DNS and DHCP
IP information can be assigned to guests via DHCP. A pool of addresses can be assigned to a virtual network switch for this purpose. Libvirt uses the
dnsmasq
program for this. An instance of dnsmasq is automatically configured and started by libvirt for each virtual network switch that needs it.
![Virtual network switch running dnsmasq](https://access.redhat.com/webassets/avalon/d/Red_Hat_Enterprise_Linux-6-Virtualization_Administration_Guide-en-US/images/c3cbe49facdac0f74515ef6db6aaf269/vn-05-switchwithdnsmasq.png)
Figure 18.4. Virtual network switch running dnsmasq