Routing networking on kvm

Solution 1:

I ran into this one a time ago. But there seem to be no way to setup the bridge on an alias interface, like eth0:1. Use the real interface eth0.

auto eth0
iface eth0 inet static

auto br0
iface br0 inet static
     bridge_ports eth0
     address 192.168.0.10
     netmask 255.255.255.0
     gateway 192.168.0.1
     broadcast 192.168.0.255
     bridge_stp off
     bridge_fd 0
     bridge_maxwait 0

Also, the address, netmask, gateway and broadcast values are the mininal configuration an interface should have. It may work with less values, but may cause weird network behavior.

As I further remember, you don't have to edit default.xml at all. You just have to make shure, that every KVM Guest has it's network interface setup to your needs.

<interface type='bridge'>
  <mac address='00:01:b4:02:00:db'/> # change per guest
  <source bridge='br0'/>             # the name of your source bridge
  <target dev='vnet0'/>              # the name, the network interface has for the guest
</interface>

The setup is to complex to cover all varieties here, like DHCP vs static setup. Did you check out the Ubuntu documentation on KVM? Helped me a lot to get into this.

Solution 2:

Why not simply set the guest to use br0? Instead of configuring it with a "network", you can configure it with a "bridge" and attach the VM to br0. example:

<interface type='bridge'>
<source bridge='br0'/>
<mac address='00:16:3e:1a:b3:4a'/>
</interface>

This way the guest will get an IP from the external net and can contact the work and host through it.

NOTE: However, the downside of using a bridge is that you won't see the client ip address of connections to your VM. Instead, the IP address of the bridge host will be logged in apache, auth.log, etc on a linux VM and similarly in a windows VM.