Bridge Networking on a KVM Host - ganeshahv/Contrail_SRE GitHub Wiki
Scenario
There is a BMS that has two NICs, say eno1 and eno2 connected to two different networks.
Requirement
We need to launch a VM inside the BMS. The VM also needs to have 2 NICs which should map respectively to the Physical NICs of the BMS.
Solution
- Edit the netplan config file of the BMS to create 2 bridges
 
root@aos-server:~# cat /etc/netplan/01-network-manager-all.yaml
network:
    version: 2
    ethernets:
        eno1:
            dhcp4: false
        eno2:
            dhcp4: false
    bridges:
      br1:
         interfaces: [eno1]
         addresses: [172.25.151.150/25]
         gateway4: 172.25.151.129
         nameservers:
           addresses: [8.8.8.8]
         dhcp4: false
         parameters:
           stp: true
      br2:
         interfaces: [eno2]
         addresses: [192.168.2.111/24]
         dhcp4: false
         parameters:
           stp: true
- Use 
virt-installto launch the VM with 2 vNICs 
sudo virt-install --name=aos-server --disk=aos_server_3.3.0-730.qcow2.gz --os-type=linux --import --noautoconsole --vcpu=8 --ram=65535 --network=bridge=br1 --network=bridge=br2
- Edit the netplan config file of the VM
 
admin@aos-server:~$ cat /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
# Automatically generated using aos-config
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses: [172.25.151.151/25]
      gateway4: 172.25.151.129
      nameservers:
              addresses: [8.8.8.8]
    eth1:
      dhcp4: no
      addresses: [192.168.2.112/24]