Translation(s): English - Français


D'autres types de configurations réseaux pour les containers sont disponibles sur la page principale LXC.

Dans le cas d'un réseau dhcp fournit par l'hôte à l'aide de libvirt, voici ici un exemple.

Dépendances

Installer libvirt

apt-get install libvirt-bin

virsh net-info default

Utiliser le réseau par défaut

(dans jessie_di_alpha_1 c'est /etc/libvirt/qemu/networks/default.xml)

root@debian:/# cat /var/lib/libvirt/network/default.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE 
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh net-edit default
or other application using the libvirt API.
-->

<network>
  <name>default</name>
  <uuid>999d40xx-22db-c999-f68x-42cfbeba99a3</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.100' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>

virsh net-start default
ifconfig -a

root@debian:/# cat /var/lib/lxc/a_container/config
[...]
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = virbr0
lxc.network.hwaddr = 00:FF:AA:00:00:01
lxc.network.ipv4 = 0.0.0.0/24
[...]

<dhcp>
  <range start="192.168.122.100" end="192.168.122.254" />
  <host mac="00:FF:AA:00:00:01" name="foo.example.com" ip="192.168.122.101" />
  <host mac="00:FF:AA:00:00:02" name="bar.example.com" ip="192.168.122.102" />
</dhcp>

virsh net-autostart default
virsh net-info default