Alocação de IP LXC usando DHCP

0

Estou tentando configurar o DHCP para meus contêineres lx sem usar o lxc-net. O motivo dessa decisão é que eu gostaria de colocar meus contêineres em redes diferentes, de modo que eles não pudessem falar uns com os outros por padrão. Eu criei e executei contêineres com sucesso usando IPs estáticos atribuídos no arquivo de configuração do contêiner antes, mas gostaria de usar um servidor DHCP no host dessa vez.

Eu instalei o dnsmasq no meu host e o configurei assim:

# /etc/dnsmasq.d/dnsmasq.lxcbr.conf
domain=local.lxc,10.10.10.0/24
interface=lxcbr
dhcp-range=lxcbr,10.10.10.1,10.10.10.200,24h
dhcp-option=option:router,10.10.10.254

De acordo com isso, o arquivo está sendo carregado corretamente:

root@host:~# service dnsmasq status
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled)
  [...]
Feb 03 19:06:39 host dnsmasq[4228]: dnsmasq: syntax check OK.
Feb 03 19:06:39 host dnsmasq[4237]: started, version 2.72 cachesize 150
Feb 03 19:06:39 host dnsmasq[4237]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect
Feb 03 19:06:39 host dnsmasq-dhcp[4237]: DHCP, IP range 10.10.10.1 -- 10.10.10.200, lease time 1d
Feb 03 19:06:39 host dnsmasq[4237]: reading /etc/resolv.conf
Feb 03 19:06:39 host dnsmasq[4237]: using nameserver upstream.nameserver.ip.here#53
Feb 03 19:06:39 host dnsmasq[4237]: using nameserver upstream.nameserver.ip.here#53
Feb 03 19:06:39 host dnsmasq[4237]: read /etc/hosts - 5 addresses

lxcbr é a interface do host na rede do contêiner:

root@host:~# ifconfig
[...]

lxcbrBind Link encap:Ethernet  HWaddr fe:60:7a:cc:56:64
          inet addr:10.10.10.254  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::7a:56ff:fe82:921f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:92 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5688 (5.5 KiB)  TX bytes:928 (928.0 B)

veth0     Link encap:Ethernet  HWaddr fe:60:7a:cc:56:64
          inet6 addr: fe80::fc60:7aff:fecc:5664/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:648 (648.0 B)  TX bytes:648 (648.0 B)

veth0 é a interface veth do contêiner:

# /var/lib/lxc/container
lxc.network.type = veth
lxc.network.name = veth0
lxc.network.flags = up
lxc.network.link = lxcbr
lxc.network.veth.pair = veth0

Eu suponho que estou fazendo algo muito estúpido, mas estou sem ideias neste momento.

Agradeço sua ajuda Christopher

    
por Cyclonit 03.02.2016 / 19:20

2 respostas

0

  1. Verifique se os pacotes UDP têm somas de verificação Em redes virtuais, as somas de verificação UDP não estão sendo calculadas. Isso faz com que o dhclient rejeite ofertas. Você pode corrigir isso dizendo ao host para recompurar as somas de verificação ausentes:

    iptables -t mangle -A POSTROUTING -p udp -j CHECKSUM --checksum-fill

  2. Execute o dhclient no contêiner Como os contêineres / etc / network / interfaces não são usados pelo LXC, você deve executar o dhclient manualmente.

por 11.02.2016 / 01:03
0

O preenchimento da soma de verificação resolveu o mesmo problema para mim. Você pode ser mais preciso especificando a interface da bridge onde seu LXC está conectado:

iptables -t mangle -A POSTROUTING -p udp -j CHECKSUM -i bridge --checksum-fill

Quanto ao dhclient automático

Configure sua interface para usar o dhcp em / etc / network / interfaces:

auto eth0
iface eth0 inet dhcp

, ative o serviço de rede no seu contêiner:

systemctl enable networking
systemctl start networking
    
por 19.04.2017 / 22:59