(For future questions such as this, you may find you get a better
response (and lower signal-noise ratio) by asking on the recently
-created
libvirt-users@xxxxxxxxxx list, as libvir-list has a very large volume
of
patches and discussion about the internals of libvirt)
On 02/08/2011 12:05 PM, Marcela Castro León wrote:
Hello
I've a lan of virtual machine configured with bridge. I've a private
lan
of 4 machine, but one of them have 2 lan-card with access to internet.
Evertything works almost fine, except that I've configured on each
guest
the static configuration of the bridge with the ip address, like this:
auto lo
iface lo inet loopback
auto eth6
iface eth6 inet static
address 192.168.1.41
network 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.10
So are you saying that you're attempting to give each guest the *same*
IP
address? There's no way that can possibly work, even if each is
connected to
a separate virtual network or bridge. Since the host's IP stack can
"see"
all of the guests' network traffic, regardless of the connection mode
you
choose, each must have a unique IP address even if they can't see each
other.
But each time I, for example, define the guest, it start with a
ascending
number of interface: eth6,eth7, eth8, etc, Now is initializing with
eth12.
There must be a mixup in the explanation - I'm understanding that you
put
the same config file in each guest, but each guest, when it starts,
shows a
different ethernet interface in its ifconfig. That doesn't seem right,
because none of the guests know about each other. Or are you saying
something different? Where are you seeing the "eth6", "eth7", ...
"eth12"?
In the guest XML config maybe?
So, it doesn't get the manual configuration I've done on the
/etc/network/interfaces.
How can avoid this way of work of the number of ethernet interface the
guest start?
Why are you doing a manual/static definition on the guest at all? It's
simpler to just leave the guest to automatically configure its eth0,
and if
you really want a particular IP address for a particular guest, handle
that
with a<host> element in the<dhcp> section of the virtual network the
guest
is connected to (or, if you're using a pure bridging setup, then in the
static hosts config of the dhcp server on that network).
A way i'm trying to solve is configuring the interface trough the guest
xml definition,
The guest xml interface configuration cannot be used to setup the IP
address, route, etc config of the guest. It is only used for two
things:
1) configuring what kind of hardware appears on the guest (but not what
name the guest gives to it!)
2) configuring how that hardware is connected to the physical network
(usually either via an existing bridge interface on the host (in order
for
the guest to appear as if its directly connected to the physical
network),
or via a "virtual network" created by libvirt (which is really just a
bridge
that's not directly connected to any physical interface, relying
instead on
the host's IP stack to route packets from the guest out to the physical
network.)
but the operation "define" on virsh accepted without error the xml i've
done, but the dumpxml doesn't show them, so, it doesn't work at all.
I've followed the instruction that said the manual "Application
development guide - a guide to application development with libvirt" on
page
71.
That document is targeted towards software developers writing
applications to manage virtual guests using the libvirt API, not for
system
administrators who are configuring virtual guests manually (or, more
likely,
by using software that uses the libvirt API, eg virsh or virt-manager).
It
likely contains more detail and less overview than what you need, which
is
probably what led to the confusion. I've included a pointer to a wiki
page
below that is more the appropriate level of information (Justin, if the
docs
you were working on are somewhere easily accessible, you can point to
those
instead.)
The whole definition of the VM is attached, but the related to
interface
is:
<interface type='bridge'>
<source bridge='br0'/>
<target dev='vnet0'/>
<protocol>
<ip address="192.168.1.41" prefix="24"/>
<route gateway="192.168.1.10"/>
</protocol>
<bridge stp="off" delay="0.01">
<interface type="ethernet" name="eth12">
<protocol>
<ip address="192.168.1.41" prefix="24"/>
<route gateway="192.168.1.10"/>
</protocol>
</interface>
</bridge>
</interface>
You are confusing the guest interface config (that is part of the
guest's
XML config, and described above), and host physical interface config
(that
is not in any way associated with guest config, but instead used to
configure the host's physical network interfaces, bridges, bonds, and
vlan
interfaces; and nearly as important, is not supported on Ubuntu
anyway).
Actual guest interface config is *much* simpler than that.
But after define, the dumpxml only show this part:
<interface type='bridge'>
<mac address='52:54:00:3c:92:9a'/>
<source bridge='br0'/>
</interface>
That's because everything else you've put in your guest config is not
actually a part of a valid guest interface config, and so is ignored.
I would appreciate any help to solve the question. The problem I've is
I
lost the access to the guest every time the libvirt change the name of
the
interface eth1,2,3, etc.
In this case I think it may be useful to start over. You've somehow
been
tricked into misunderstanding the way that network configuration in
libvirt
works, confusing host interface config with guest interface config, and
the
resulting config bears little resemblance to what would actually work.
==
The first step is to read this page:
http://wiki.libvirt.org/page/Networking
to get a basic overview.
==
Second step: you should decide which of the three methods of connecting
to guests to the physical network you want to use:
1) NATed
2) routed
3) bridged
The simplest is (1), and that will probably work just fine as long as
1)
you don't need incoming connections to the guests, and 2) you're not
concerned about getting the last fraction of an ounce of performance
out of
the network.
Depending on which of those 3 you decide to use:
==
Third step: follow the instructions to either create a bridge interface
on the host connected to a physical network interface (for (3)), or to
create a libvirt virtual network using one of the two modes ((1) or (2)
-
actually the stock libvirt config already has a "default" network that
is
probably adequate for (1), and unless you understand IP routing very
well,
you'll likely want to avoid (2)).
Once the physical network is setup:
==
Fourth step: define your guests. In each guest, you'll have an
<interface> element, but it will be much simpler than what you've
previously
tried. For bridged mode, the interface section would look like this:
<interface type='bridge'>
<source bridge='br0'/>
</interface>
Depending on the guest, you may want to specify what type of hardware
is
presented to the guest (default is rtl, which almost always works, but
is
not the best perfrorming), in particular, if the guest supports
virtio-net,
you'll want to add this into the<interface> element:
<model type='virtio'/>
For NATed or routed mode, the guest's interface definition would look
like this:
<interface type='network'>
<source network='default'/>
</interface>
(replace "default" with the name of the network you've defined, if
you've
defined your own). In this case also, you can add a<model type='...'/>
if
appropriate.
Note that I don't put anything in the<interface> element about MAC
address, target device, or bus address. Those are all setup
automatically by
libvirt the first time you start the guest, and it will make sure that
the
guests don't interfere with each other.
==
Fifth step: only if you need a particular guest to have a particular
fixed IP address, either 1) edit the network config file on the guest,
2)
add a static host to the libvirt virtual network definition (giving the
MAC
address provided to the guest by libvirt during the initial guest
startup)
with a<host> element added to the<dhcp> element of the network;
details
are here:
http://www.libvirt.org/formatnetwork.html
or 3) if you're using the bridged method to connect to the physical
network, again either configure the guest's own config file, or add a
static
host definition to the dhcp server running on your physical network.
If you still have problems don't hesitate to send another mail
(although,
as I said at the top, sending to libvirt-users@xxxxxxxxxx may yield
better
results than libvir-list@xxxxxxxxxx).