There are a lot of configuration used for Kvm-networking. But i'm not able to get to the guest from the host or outside. I'm working on Ubuntu 11.04. On the guest i've a WindowsXp with dhcp.

I want the guest to be in the same network of the host. i've tried to use ip aliases

i've set up bridged networking in /etc/network/interfaces

auto eth0
iface eth0 inet manual

auto eth0:1
iface eth0:1 inet static
address 192.168.0.11
netmask 255.255.255.0

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

then changed default network in /etc/libvirtd/qemu/network/default.xml

<network>
<name>default</name>
<uuid>831a93e1-0b84-0b0e-9ca2-23c407983968</uuid>
<forward mode='route'/>
<bridge name='virbr0' stp='on' delay='0' />
 <ip address='192.168.122.1' netmask='255.255.255.0'>
  <dhcp>
    <range start='192.168.122.100' end='192.168.122.254' />
    <host mac='52:54:00:7c:df:88' name='vm' ip='192.168.122.99' />
  </dhcp>
</ip>
</network>

the network in /etc/libvirt/qemu/vm.xml

<interface type='network'>
  <mac address='52:54:00:7c:df:88'/>
  <source network='default'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

the guest from dhcp gets the correct ip. finally direct traffic from external interfaces to internal and back

sudo iptables -t nat -A PREROUTING -d 192.168.0.11 -j DNAT --to-destination 192.168.122.99

sudo iptables -t nat -A POSTROUTING -d 192.168.122.99 -j SNAT --to-source 192.168.0.11

so in the end the configuration is this:

$> brctl show
bridge name          bridge id      STP enabled interfaces
br0             8000.0026b902076d   no      eth0
virbr0          8000.fe54007cdf88   yes     vnet0

$> route
Tabella di routing IP del kernel
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 br0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
link-local      *               255.255.0.0     U     1000   0        0 br0
default         192.168.0.1     0.0.0.0         UG    100    0        0 br0

$> ifconfig

br0       Link encap:Ethernet  HWaddr 00:26:b9:02:07:6d  
      indirizzo inet:192.168.0.10  Bcast:192.168.0.255  Maschera:255.255.255.0

eth0      Link encap:Ethernet  HWaddr 00:26:b9:02:07:6d  
      indirizzo inet6: fe80::226:b9ff:fe02:76d/64 Scope:Link

eth0:1    Link encap:Ethernet  HWaddr 00:26:b9:02:07:6d  
      indirizzo inet:192.168.0.11  Bcast:192.168.0.255  Maschera:255.255.255.0

virbr0    Link encap:Ethernet  HWaddr fe:54:00:7c:df:88  
      indirizzo inet:192.168.122.1  Bcast:192.168.122.255  Maschera:255.255.255.0

vnet0     Link encap:Ethernet  HWaddr fe:54:00:7c:df:88  
      indirizzo inet6: fe80::fc54:ff:fe7c:df88/64 Scope:Link

what is wrong? Or how i can set up a guest visible outside the host?

link|improve this question
feedback

2 Answers

up vote 2 down vote accepted

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.

link|improve this answer
feedback

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.

link|improve this answer
was the windows firewall on the client that was blocking all the request... solved! – nevios May 20 '11 at 13:58
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.