Configuring bridge for libvirt/KVM virtual machine

Using interfaces fil

Using your favorite editor open /etc/network/interfaces replace the text with something like this:

# This file describes the network interfaces available on your system
 # and how to activate them. For more information, see interfaces(5).

 # The loopback network interface
 auto lo br0
 iface lo inet loopback

# Set up interfaces manually, avoiding conflicts with, e.g., network manager
 iface enp3s0 inet manual

 # Bridge setup
 iface br0 inet static

    bridge_ports enp3s0
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0
Replace enp3s0 with your NIC (Network Interface Card) name and local IP and gateway like with your local IPs. In the command line run:
# systemctl restart networking
Create a file named foo.xml (the name of this xml file is not important you can name it with whatever name you like) and have it include the following lines:

  <forward mode="bridge"/>
  <bridge name="br0"/>
save and close. In the command line run the following:

# virsh net-define foo.xml
# virsh net-list --all
# virsh net-start BR0
# virsh net-list --all
This will connect br0 bridge with virsh and activate the connection. As you can see the name of this connection is BR0. To list all of your virtual machine simply run:
$ virsh list --all
Suppose that one of your virtual machines is VM1. Connect this machine to your bridge (br0) is done by editing the machine configuration file. Simply run the following command
$ virsh edit VM1
Look for the tag interfaces and replace it with the following:

<interface type='bridge'>
    <mac address='52:54:00:f1:ca:28'/>
    <source bridge='br0'/>
    <model type='virtio'/>   
save and close. You may now run virtual machine VM1, but network may not be reachable form this machine. This is due to iptables configurations specified in /proc/sys/net/bridge/bridge-nf-call-iptables . You may disable those rules by running (in the command line):

# echo 0 > /proc/sys/net/bridge/bridge-nf-call-iptables
Now you can run VM1, from the command line run:

# virsh start VM1
# virt-viewer VM1
Disclaimer Privacy