VMmanager 5 KVM: Administrator guide
Do you make friends with the documentation?
Share your opinion and complete a small poll
Take a survey

Create virtual machines with several network cards (NIC)

Several network cards in virtual machines allow, for example, combining several virtual machines by the local network. 

To connect several network cards to a virtual machine, on the VM creation form you need to specify the VM template which resources contain several networks.  The same number of network cards as specified in the VM template will be connected to the newly created virtual machine. Every interface will be associated with the corresponding network libvirt. The network interfaces are connected one after another: the virtual interface eth0 will be associated with the first network, eth1 - to the second, etc.

When starting a virtual machine, libvirt connects the corresponding network to the bridges specified in the network settings.

E.g. the virtual machine with three network interfaces is created on the cluster node where three networks are configured.

The configuration in libvirt will look like this:

# virsh dumpxml  vmmultinic
 <domain type='kvm' id='2'>
   <name>vmmultinic</name>
   <uuid>bf23ea1f-458f-8be3-1c3e-2e053b3489a3</uuid>
   ...
   <devices>
     ...
     <interface type='network'>
       <mac address='52:54:00:61:ac:df'/>
       <source network='Basic'/>
       <target dev='vnet1'/>
       <model type='virtio'/>
       <filterref filter='vm-vmmultinic'>
         <parameter name='IP' value='172.31.224.13'/>
         <parameter name='IPV6' value='2a01:230::bef6:85ff:fed7:4062'/>
       </filterref>
       <alias name='net0'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </interface>
     <interface type='network'>
       <mac address='52:54:00:6f:d0:1e'/>
       <source network='B2'/>
       <target dev='vnet2'/>
       <model type='virtio'/>
       <alias name='net1'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
     </interface>
     <interface type='network'>
       <mac address='52:54:00:9f:11:bb'/>
       <source network='b3'/>
       <target dev='vnet3'/>
       <model type='virtio'/>
       <alias name='net2'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
     </interface>
     ...
   </devices>
   ...
 </domain>

The list of network bridges:

# brctl show
bridge name	bridge id		STP enabled	interfaces
virbr0		8000.525400fb1ab4	yes		virbr0-nic
vmbr0		8000.525400ff6734	no		eth0
                                    vnet1
vmbr1		8000.fe54006fd01e	no		vnet2
vmbr2		8000.fe54009f11bb	no		vnet3

We can see that the first interface VM (eth0) is connected to the bridge vmbr0 and to the main interface of the cluster node. The second interface eth1 of the virtual machine is connected to the bridge vmbr1,  the third one - to vmbr2

All other virtual machines with the same template will be connected in the same way. This means that all second interfaces of such VM will be grouped into the single network. 

E.g. all the cluster nodes are combined by the internal network 10.1.1.0/24 through the second interfaces eth1. To grant access to that network for the virtual machine, you need to connect the interface eth1 of the cluster node and the bridge vmbr1. After that, the virtual machines will be combined with the internal network of the cluster through the second interfaces.