8

I'm having trouble setting up KVM w. bridged networking in Ubuntu 10.10. I'm starting my VM through virsh, after this I can see the kvm process and vnet device on the host machine, but the new interface doesn't ever get an IPv4 address so I can't use the VM! Below is a readout of what I can see once the VM has started.

root@robin-desktop:~# virsh start meerkat
Domain meerkat started

root@robin-desktop:~# ps aux | grep kvm
root      1411  0.0  0.0      0     0 ?        S    18:20   0:00 [kvm-irqfd-clean]
119       3436 73.7  3.5 1213320 141076 ?      Sl   18:48   0:05 /usr/bin/kvm -S -M pc-0.12 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name meerkat -uuid dbf905dd-b05d-5c81-5fe4-ad421cd50ece -nographic -nodefaults -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/meerkat.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot c -drive file=/home/robin/kvm/meerkat/ubuntu-kvm/tmp6pwohf.qcow2,if=none,id=drive-ide0-0-0,boot=on,format=qcow2 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:06:7e:9c,bus=pci.0,addr=0x3 -net tap,fd=40,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
root      3455  0.0  0.0  11340   872 pts/0    S+   18:49   0:00 grep --color=auto kvm
root@robin-desktop:~# 
root@robin-desktop:~# ifconfig 
br0       Link encap:Ethernet  HWaddr e0:cb:4e:bb:99:07  
          inet addr:192.168.1.15  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::e2cb:4eff:febb:9907/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2948 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2904 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1285644 (1.2 MB)  TX bytes:612230 (612.2 KB)

eth0      Link encap:Ethernet  HWaddr e0:cb:4e:bb:99:07  
          inet6 addr: fe80::e2cb:4eff:febb:9907/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3835 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3845 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1817408 (1.8 MB)  TX bytes:785533 (785.5 KB)
          Interrupt:47 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:63 errors:0 dropped:0 overruns:0 frame:0
          TX packets:63 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4869 (4.8 KB)  TX bytes:4869 (4.8 KB)

vnet0     Link encap:Ethernet  HWaddr fe:54:00:06:7e:9c  
          inet6 addr: fe80::fc54:ff:fe06:7e9c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:0 (0.0 B)  TX bytes:4137 (4.1 KB)

root@robin-desktop:~#

Digging around a little, there may be clues in the daemon log file:

root@robin-desktop:~# tail -7 /var/log/daemon.log
Dec  1 18:48:55 robin-desktop NetworkManager[3342]:    SCPlugin-Ifupdown: devices added (path: /sys/devices/virtual/net/vnet0, iface: vnet0)
Dec  1 18:48:55 robin-desktop NetworkManager[3342]:    SCPlugin-Ifupdown: device added (path: /sys/devices/virtual/net/vnet0, iface: vnet0): no ifupdown configuration found.
Dec  1 18:48:55 robin-desktop NetworkManager[3342]: <warn> /sys/devices/virtual/net/vnet0: couldn't determine device driver; ignoring...
Dec  1 18:48:55 robin-desktop modem-manager: (net/vnet0): could not get port's parent device
Dec  1 18:48:56 robin-desktop avahi-daemon[3354]: Joining mDNS multicast group on interface vnet0.IPv6 with address fe80::fc54:ff:fe06:7e9c.
Dec  1 18:48:56 robin-desktop avahi-daemon[3354]: New relevant interface vnet0.IPv6 for mDNS.
Dec  1 18:48:56 robin-desktop avahi-daemon[3354]: Registering new address record for fe80::fc54:ff:fe06:7e9c on vnet0.*.

I've tried switching off avahi and network-manager - no difference.

Does anyone have any experience of similar issues? I had this stuff working OK on Ubuntu 9.10!

Thanks.

Edit: here's some brctl output:

root@robin-desktop:~# brctl show

bridge name bridge id       STP enabled interfaces
br0     8000.e0cb4ebb9907   no      eth0
                            vnet0

Edit 2: this is the network interface file on the host machine

robin@robin-desktop:~$ cat /etc/network/interfaces 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

Should I set bridge_stp on?

Edit3: Here's the libvirt xml config, this was initially created by ubuntu-vmbuilder, I've hacked at it a little

<domain type='kvm'>
  <name>meerkat</name>
  <uuid>dbf905dd-b05d-5c81-5fe4-ad421cd50ece</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/robin/kvm/meerkat/ubuntu-kvm/tmp6pwohf.qcow2'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    </disk>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:06:7e:9c'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </memballoon>
  </devices>
</domain>
Robin
  • 305
  • 1
  • 3
  • 9
  • 1
    Is the `vnet0` interface being slaved to the bridge `br0`? What does `brctl show br0` say? – Steven Monday Dec 01 '10 at 19:24
  • I think perhaps you've gotten a bit confused? YOU have to assign the IP address to your VM's NIC, so you should already know it. The output you've posted shows the config of the host, not of the VM. To me, the host's networking config seems fine. – Steven Monday Dec 02 '10 at 06:26
  • Hi Steven - I was hoping that the IP address would be assigned by network router - please see me `/etc/network/interfaces` file above – Robin Dec 02 '10 at 19:22

3 Answers3

6

-A FORWARD -m physdev --physdev-is-bridged -j ACCEPT in /etc/sysconfig/iptables, I added this line to make my kvm work right.

Alexred
  • 68
  • 4
xiaotie
  • 61
  • 1
  • 2
  • 5
    This is most likely the solution. Alternatively add these lines to /etc/sysctl.conf: `net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 ` – AndreasM Aug 03 '11 at 13:46
  • 1
    My VM's networking suddenly broke and this got it working again. Awesome! – AVH May 20 '17 at 09:44
0

I define the interface on the virutal machine in /etc/network/interfaces using a static address. The virtual machine will need to be defined with an ethernet interface. A vnet device created on the server for the virtual machine. The vnet interface should appear on the server as up with no addresses defined. The vnet device will appear as an eth type interface on the vm.

If the above output is for your server, the br0 address on your server should be fine for the virtual machine. eth0 on the server should have whatever address is required for external access. You should also have a vnet0 device which I don't see.

EDIT: I also shutdown the autostart of the network by virsh. This is the /etc/network/initerfaces definition for one of my bridges. I updated my dhsmasq configuration accoringly.

auto virbr0
iface virbr0 inet static
        address 192.168.10.1
        netmask 255.255.255.224
        pre-up brctl addbr virbr0
        post-down brctl delbr virbr0

The matching network defintion is

<network>
  <name>default</name>
  <uuid>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</uuid>
  <bridge name='virbr0' stp='on' forwardDelay='0' />
  <domain name='virt.example.com'/>
</network>
BillThor
  • 27,737
  • 3
  • 37
  • 69
  • -1 there is vnet0 device in output – Saurabh Barjatiya Dec 02 '10 at 04:42
  • Add output of "virsh dumpxml meerkat" and "virsh net-dumpxml " where VM is getting connected to question. – Saurabh Barjatiya Dec 02 '10 at 04:43
  • Hi Saurabh - I've actually switched off the virsh networking because I set up my own bridge - as above. Is this wrong? When I run `virsh net-list` nothing shows up - I commented out the network in /etc/libvirt/qemu/networks/autostart/ – Robin Dec 02 '10 at 19:25
0

Please check your firewall settings in the host machine. I once got bitten by this - took me hours to find the problem. The VM must be able to send and receive dhcp packets through the bridge and back across it again, via the host firewall rules.

sybreon
  • 7,405
  • 1
  • 21
  • 20