[libvirt-users] Network/bridge questions

Laine Stump laine at laine.org
Sat Feb 5 20:36:38 UTC 2011


On 02/05/2011 01:06 AM, Alex wrote:
> Hi,
>
> I have an fc14 install and would like to install a few kvm guests but
> am having difficulty with the networking. On the host I have disabled
> NetworkManager and configured a bridge which has eth0, the only
> physical interface on the server.
>
> I have a dhcp server on the local lan, and if I add a mac address
> entry to my dhcpd.conf, the guest will find an IP from there. I think
> somehow the guest interface is not properly being routed through the
> virtual gateway created by libvirtd, and is instead just routed
> through br0 directly on the host. What am I missing?

You're mixing up two different modes of guest network connection:

1) bridge mode - the guest interface definition has <source 
bridge='xxx'/> (where 'xxx' is the name of a bridge device on the host 
that has a physical interface directly connected to it). In this case, 
packets from the guest travel from qemu through a tap device to the 
bridge (eg "br0") and from there directly out the physical interface.

2) virtual network mode - the guest interface definition has <source 
network='xxx'/> (where 'xxx' is the name of a virtual network defined in 
libvirt). The virtual network is in reality a bridge device that has *no 
connected physical devices*; traffic from the guest will go from qemu 
through a tap device to the bridge, and from there (possibly be NATed 
and) be given to the IP routing stack of the host, which will decide 
which physical interface, if any, to route the packet out.

If you are using the first mode, your guest will acquire any dhcp 
address from the dhcp server on the local physical LAN, and traffic 
will, as explained above, not be routed through any virtual network 
created by libvirt.

If you want the guest to behave as if it were connected directly to the 
physical network, use bridged mode. If you want to the guest to be on a 
separate subnet that lives completely on the host, and only reach the 
physical network via the IP routing stack of the host, then use one of 
the virtual network modes.

In your question above, you've setup the guest to use bridged mode, but 
then expect it to behave as if you'd used one of the virtual network 
modes. If the latter is what you really want, then the XML of the 
interface definition should look like what I show below, just after your 
current definition.


> Here is some relevant output from some of the things I know:
>
> # # brctl show
> bridge name     bridge id               STP enabled     interfaces
> br0             8000.485b3961b55c       no              eth0
>                                                          vnet0
> virbr0          8000.000000000000       yes
>
> I don't understand what purpose the vnet0 has, or even how it got
> there in the first place. Is it necessary, or did I do something wrong
> here?
>
> # virsh net-list --all
> Name                 State      Autostart
> -----------------------------------------
> default              active     yes
>
> > From the guest xml file in /etc/libvirt/qemu/
>
>      <interface type='bridge'>
>        <mac address='52:54:00:a8:c5:9d'/>
>        <source bridge='br0'/>
>        <model type='virtio'/>
>        <address type='pci' domain='0x0000' bus='0x00' slot='0x03'
> function='0x0'/>
>      </interface>

To connect via libvirt's virtual network (in this case, the network 
named "default", which operates in NATed mode), change your interface 
definition as follows:

     <interface type='network'>
       <mac address='52:54:00:a8:c5:9d'/>
       <source network='default'/>
       <model type='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </interface>

See http://www.libvirt.org/formatdomain.html#elementsNICS for a more 
detailed explanation.

> I've also flushed the firewall rules, so I'm sure the dhcp request
> isn't being blocked. I've also tried changing the br0 above to virbr0,
> with no change.
>
> This is from "net-edit default" in virsh:
>
> <network>
>    <name>default</name>
>    <uuid>3d1f153f-fc0f-4de5-98c8-7f99f96f34d6</uuid>
>    <forward mode='nat'/>
>    <bridge name='virbr0' stp='on' delay='0' />
>    <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>
>
> Sure would appreciate any ideas you may have.
>
> Thanks,
> Alex
>
> _______________________________________________
> libvirt-users mailing list
> libvirt-users at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-users
>




More information about the libvirt-users mailing list