[libvirt-users] LXC: unable to configure networking for LXC

Avi Weit WEIT at il.ibm.com
Thu Mar 11 14:36:56 UTC 2010


Hi Robin,

Thanks for this info,

I tried the first example provided under
http://www.libvirt.org/formatdomain.html#elementsNICS - Virtual Network
which I can see an example that defines the following:

<interface type='network'>
      <source network='default'/>
</interface>

and that is what I tried to create and start the container with. My
understanding, but I may be wrong is that IP, MAC and tun device will
automatically be created and assigned with values by libvirt. I understand,
that this type of configuration uses the Libvirt's default network which is
configured below and has a range of dhcp IPs.

[root at enc12 avi]# virsh net-dumpxml default
<network>
  <name>default</name>
  <uuid>9c949214-562a-4c31-a098-235dd368caca</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>

explicitly defining the container with  IP of 192.168.122.2 - did not work.

Here is the interface portion of the XML I defined the container with

   <interface type='network'>
      <source network='default'/>
      <ip address ='192.168.122.2'/>
   </interface>


In LXC tools I did not have to configure anything from inside container.
All settings - tun, internal network interface of the container, MAC and IP
were created automatically. I would like to verify if I indeed must to
configure the networking from *inside* the container?

Thanks again,
- Avi

Robin Green <greenrd at greenrd.org> wrote on 09/03/2010 03:52:41 AM:

> From:
>
> Robin Green <greenrd at greenrd.org>
>
> To:
>
> Avi Weit/Haifa/IBM at IBMIL
>
> Cc:
>
> libvirt-users at redhat.com
>
> Date:
>
> 11/03/2010 03:24 PM
>
> Subject:
>
> Re: [libvirt-users]  LXC: unable to configure networking for LXC
>
> At Thu, 11 Mar 2010 14:08:48 +0200,
> Avi Weit wrote:
> > I would like to set up sshd under an LXC application container and to
be
> > able to connect into it from the host. I was able to achieve that with
LXC
> > tools CLI after setting up a bridge via brctl and creating a proper
> > lxc.conf file for lxc-execute to use. However, I am unable to do so via
> > libvirt.
>
> As far as I know, libvirt always assumes that the guest is responsible
> for obtaining an IP address e.g. using DHCP (which makes perfect sense in
> the context of virtualisation technologies which emulate a PC). So at
> this time, I think you need to have a script which runs dhclient before
> running sshd.
>
> Another alternative is just to run a full Linux distribution inside LXC,
> and then the LXC guest's init will be responsible for bringing up the
> network. However, I haven't managed to do this (init just dies
> immediately when I've tried it, on Fedora 12).
>
> Regards,
> --
> Robin Green




More information about the libvirt-users mailing list