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?