Ubuntu 10.04; kvm bridged networking not working with public ip addresses

bridgekvm-virtualizationnetworkingUbuntu

I have a dedicated hosted server box with ubuntu 10.04 64 bit installed. I would like to run kvm with ubuntu 8.04 installed for some php 5.2 compatible apps(they don't work right with php 5.3, the default in ubuntu 10.04).

I installed KVM as instructed at https://help.ubuntu.com/community/KVM/Installation . I installed the vm using virt-manager. I never could figure out how use virt-install or any of those automated installers. I just installed it using the disc. I set up bridged networking as per https://help.ubuntu.com/community/KVM/Networking . However, the bridged connection doesn't work.

Here's my /etc/network/interfaces on the host, running ubuntu 10.04. (with specific public ip blanked)

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address xx.xx.xx.xx
        netmask 255.255.255.248
        gateway xx.xx.xx.xa
        bridge_ports eth0
        bridge_stp on
        bridge_fd 0
        bridge_maxwait 10
`

Here's my /etc/network/interfaces on the guest, running ubuntu 8.04.

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address xx.xx.xx.xy
netmask 255.255.255.248
gateway xx.xx.xx.xa

The two vm's can communicate to each other. But, the guest vm can't access anyone in the real world.

Here's my /etc/libvirt/qemu/store_804.xml

<domain type='kvm'>
  <name>store_804</name>
  <uuid>27acfb75-4f90-a34c-9a0b-70a6927ae84c</uuid>
  <memory>2097152</memory>
  <currentMemory>2097152</currentMemory>
  <vcpu>2</vcpu>
  <os>
            <type arch='x86_64' machine='pc-0.12'>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>restart</on_crash>
      <devices>
            <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/store_804.img'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <disk type='block' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
            </disk>
                    <interface type='bridge'>
      <mac address='52:54:00:26:0b:c6'/>
      <source bridge='br0'/>
      <model type='virtio'/>
        </interface>
    <console type='pty'>
      <target port='0'/>
    </console>
    <console type='pty'>
      <target port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
            <sound model='es1370'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>
  </devices>
</domain>

Any idea where I've gone wrong?

Best Answer

You can't use bridge mode in such environment, you can almost be certain that the hosting partner will block all traffic not originating from the MAC-address of the real NIC in your server. You'll need to setup a routed setup, in which all traffic to/from VM guests are send through your host. One way of doing this is using the native Libvirt support of routed networking ("forward mode="route" in the XML-configuration of the network).

There's a German server hosting company who has written a couple of guides on the subject, you can use Google translate to translate it into English, in case you don't understand German :) http://wiki.hetzner.de/index.php/Kategorie:KVM