1

OS: Ubuntu 16.04.3

Configuring a KVM Bridge between my ethernet card (eno1), guest(s) (vnet0), and bridge (br0)

I have my bridge working properly with my network card so that my machine has WAN access to my router.

I have been following these guides:

https://jamielinux.com/docs/libvirt-networking-handbook/bridged-network.html

No IPv4 address assigned to KVM VM

https://wiki.debian.org/BridgeNetworkConnections

Here are the interface settings for br0: # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback

# Ethernet
iface eno1 inet manual

# Bridge
auto br0 
iface br0 inet static
        hwaddress ether 40:16:7e:28:0e:60
        address 192.168.1.200
        netmask 255.255.255.0
        network 192.168.1.0
        gateway 192.168.1.254
        broadcast 192.168.1.255

        bridge_ports eno1
        bridge_stp off 
        bridge_fd 0

        dns-nameservers 192.168.1.254 8.8.8.8 8.8.8.4

When brought up:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether 40:16:7e:28:0e:60 brd ff:ff:ff:ff:ff:ff
3: wlp13s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 54:27:1e:97:32:16 brd ff:ff:ff:ff:ff:ff
53: vboxnet0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
82: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:53:24:54:a5 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever
181: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 40:16:7e:28:0e:60 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.200/24 brd 192.168.1.255 scope global br0
       valid_lft forever preferred_lft forever
    inet6 2001:569:737d:a300:4216:7eff:fe28:e60/64 scope global mngtmpaddr dynamic 
       valid_lft 14700sec preferred_lft 14400sec
    inet6 fe80::4216:7eff:fe28:e60/64 scope link 
       valid_lft forever preferred_lft forever
182: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN group default qlen 1000
    link/ether fe:57:13:a9:fb:22 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc57:13ff:fea9:fb22/64 scope link 
       valid_lft forever preferred_lft forever

Finally I have this in /etc/sysctl.d/bridge.conf

net.bridge.bridge-nf-call-ip6tables=0
net.bridge.bridge-nf-call-iptables=0
net.bridge.bridge-nf-call-arptables=0

reloaded with:

sysctl -p /etc/sysctl.d/bridge.conf

Ok on the VM side of things I am using terraform with a libvirt provider https://github.com/dmacvicar/terraform-provider-libvirt

I am not going to show the terraform file as its outside the scope but the xml it generates is as such.

<domain type='kvm' id='40'>
  <name>ubuntu1</name>
  <uuid>4bd33601-b6a1-4863-a230-8b3ea4dfa48c</uuid>
  <memory unit='KiB'>524288</memory>
  <currentMemory unit='KiB'>524288</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-xenial'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/ubuntu-qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/commoninit.iso'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='ea:57:13:a9:fb:22'/>
      <source bridge='br0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/18'/>
      <target type='isa-serial' port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/18'>
      <source path='/dev/pts/18'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <console type='pty'>
      <source path='/dev/pts/19'/>
      <target type='virtio' port='1'/>
      <alias name='console1'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-ubuntu1/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='spice' port='5900' autoport='yes'>
      <listen type='address'/>
    </graphics>
    <video>
      <model type='cirrus' vram='16384' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </rng>
  </devices>
  <seclabel type='dynamic' model='apparmor' relabel='yes'>
    <label>libvirt-4bd33601-b6a1-4863-a230-8b3ea4dfa48c</label>
    <imagelabel>libvirt-4bd33601-b6a1-4863-a230-8b3ea4dfa48c</imagelabel>
  </seclabel>
</domain>

Once the VM is up and running this is ip addr returns:

And brctl show:

bridge name bridge id       STP enabled interfaces
br0     8000.40167e280e60       no             eno1
                                              vnet0
docker0     8000.0242532454a5   no      

and virsh addrs shows nothing for the interface for me to connect too:

> virsh domifaddr ubuntu1 vnet0
 Name       MAC address          Protocol     Address
-------------------------------------------------------------------------------

I am expecting the ip address to be filled based on the bridges connection to my router. My home router has a dhcp reservation for the host but I would expect the guests to be getting an ip as well?

Any guidance on how to get an IP for VM available on the LAN would be appreciated.

5
  • the ip is configured inside thevm
    – c4f4t0r
    Jan 12, 2018 at 9:49
  • @c4f4t0r do you mean that it needs to be configured or that is it configured?
    – paxsonsa
    Jan 12, 2018 at 9:56
  • to be configured, with your bridge you only provide an ethernet interface to your vm, when you are in bridge mode.
    – c4f4t0r
    Jan 12, 2018 at 10:01
  • @c4f4t0r hmmm I am trying a few things here to try and get an ip. Do I need to add the IP into the interface (in the xml) or create a network for it. I am not very clear on how to get said IP on the machine. I know the ip addr add if one way but maybe you could provide a deeper insight?+
    – paxsonsa
    Jan 12, 2018 at 10:58
  • you need to configure the ip address inside the vm, not in the xml, so logging as root and configure the ip on your vm, not on physical host.
    – c4f4t0r
    Jan 12, 2018 at 13:32

0

You must log in to answer this question.

Browse other questions tagged .