libvirt/kvm networking

Aljosa Mohorovic aljosa.mohorovic at gmail.com
Fri Jun 19 15:12:47 UTC 2009


file attached are my current settings, guest machine has no connectivity.
my guess is that /etc/libvirt/qemu/networks/default.xml is wrong but i
have no idea if  i should use br0 or virbr0  or something else.

howto on http://howtoforge.org/ for jaunty uses static ip where i'm
trying to create environment for my laptop and pc at work which all
use dhcp (don't know if there is a difference) and there is no mention
of /etc/libvirt/qemu/networks/default.xml.
http://libvirt.org/formatnetwork.html has description and examples of
config but i'm not sure what should i use.
i've tried several combinations with no success.

i've created image with this command:
/usr/bin/vmbuilder kvm ubuntu --suite jaunty --flavour virtual
--rootsize=5000 --mem 1024 --mirror
http://hr.archive.ubuntu.com/ubuntu --libvirt qemu:///system -d
my_new_vm --hostname my_hostname --bridge=br0

any idea what i'm doing wrong?

Aljosa Mohorovic
-------------- next part --------------
# ifconfig                                                                                                                                                                                                
br0       Link encap:Ethernet  HWaddr 00:1d:60:36:42:1d                                                                                                                                                                                      
          inet addr:10.0.2.103  Bcast:10.0.2.255  Mask:255.255.255.0                                                                                                                                                                         
          inet6 addr: fe80::21d:60ff:fe36:421d/64 Scope:Link                                                                                                                                                                                 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                                                                                                                                                                                 
          RX packets:31 errors:0 dropped:0 overruns:0 frame:0                                                                                                                                                                                
          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0                                                                                                                                                                              
          collisions:0 txqueuelen:0                                                                                                                                                                                                          
          RX bytes:2931 (2.9 KB)  TX bytes:7972 (7.9 KB)                                                                                                                                                                                     

eth0      Link encap:Ethernet  HWaddr 00:1d:60:36:42:1d  
          inet6 addr: fe80::21d:60ff:fe36:421d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:146128 errors:0 dropped:0 overruns:0 frame:0
          TX packets:113611 errors:0 dropped:0 overruns:0 carrier:1
          collisions:0 txqueuelen:1000                             
          RX bytes:171755120 (171.7 MB)  TX bytes:59362919 (59.3 MB)

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:1207 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1207 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0                              
          RX bytes:1227464 (1.2 MB)  TX bytes:1227464 (1.2 MB)   

virbr0    Link encap:Ethernet  HWaddr 86:27:16:7e:36:ad  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          inet6 addr: fe80::8427:16ff:fe7e:36ad/64 Scope:Link               
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0                
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0             
          collisions:0 txqueuelen:0                                         
          RX bytes:0 (0.0 B)  TX bytes:1758 (1.7 KB)                        

# 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

# cat /etc/libvirt/qemu/my_hostname.xml
<domain type='kvm'>
  <name>my_hostname</name>
  <uuid>cfce1aeb-3f9e-444f-5e5d-b4bf52b25481</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='i686' machine='pc'>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'>
      <source file='/home/aljosa/Documents/KVM/my_new_vm/disk0.qcow2'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <interface type='bridge'>
      <mac address='52:54:00:1f:f0:d3'/>
      <source bridge='br0'/>
    </interface>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'/>
  </devices>
</domain>

# cat /etc/libvirt/qemu/networks/default.xml
<network>
        <name>default</name>
        <uuid>ec6f8ce7-ad0f-eea7-d9ed-dc460cf47023</uuid>
        <bridge name="virbr0" />
        <forward mode="nat"/>
        <ip address="192.168.122.1" netmask="255.255.255.0">
          <dhcp>
            <range start="192.168.122.2" end="192.168.122.254" />
          </dhcp>
        </ip>
</network>


More information about the ubuntu-server mailing list