Generate libvirt network XML definitions for KVM virtual machines. NAT, bridged, isolated, and macvtap network types with virsh commands and optional netplan bridge config.
KVM (Kernel-based Virtual Machine) uses libvirt to manage virtual networks. Each virtual network is defined as an XML file and activated with <code>virsh net-define</code> and <code>virsh net-start</code>. The four network types cover the main use cases: NAT for outbound-only internet access from VMs, bridged for placing VMs directly on the physical network, isolated for private VM-to-VM communication with no external access, and macvtap for direct hardware attachment.
Select the network type, enter the network name and bridge interface name, and fill in the IP range for NAT or Isolated networks. For bridged networks, specify the host interface to attach to. The XML tab shows the complete libvirt network definition ready to save and define with <code>virsh net-define</code>. The Commands tab shows the three virsh commands needed to define, start, and configure autostart for the network.
The most common setup for homelab and production is a NAT network for management VMs and a bridged network for VMs that need to be on the same subnet as physical hosts. For VMs that require VLAN tagging, enable the VLAN ID option in bridged mode and ensure the host interface is a VLAN-capable trunk. For macvtap mode, VMs connect directly to the physical NIC using a virtual interface in bridge submode, which bypasses the host bridge entirely.