Lxc don't assign ip to container

networking

#1

Hi all, after some days of work and try I ask help.
When I start a new container lxc don’t give any address to the container!

This is my /etc/lxc/default.conf

lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx

This is my /etc/default/lxc-net

USE_LXC_BRIDGE=“true”
LXC_BRIDGE=“lxcbr0”
LXC_ADDR=“10.0.3.1”
LXC_NETMASK=“255.255.255.0”
LXC_NETWORK=“10.0.3.0/24”
LXC_DHCP_RANGE=“10.0.3.2,10.0.3.254”
LXC_DHCP_MAX=“253”

This is my ifconfig -a

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.202 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 2001:b07:5d27:bd9a:7ae3:b5ff:fe07:f9d0 prefixlen 64 scopeid 0x0
inet6 fe80::7ae3:b5ff:fe07:f9d0 prefixlen 64 scopeid 0x20
ether 78:e3:b5:07:f9:d0 txqueuelen 1000 (Ethernet)
RX packets 129309 bytes 145649400 (138.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 63720 bytes 6429678 (6.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xef000000-ef01ffff

eth1: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 78:e3:b5:07:f9:d1 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xef060000-ef07ffff

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 2 bytes 164 (164.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2 bytes 164 (164.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lxcbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.3.1 netmask 255.255.255.0 broadcast 0.0.0.0
inet6 fe80::216:3eff:fe00:0 prefixlen 64 scopeid 0x20
ether 00:16:3e:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 24 bytes 1520 (1.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 1100 (1.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vethQAQT1O: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::fcef:75ff:feb3:4515 prefixlen 64 scopeid 0x20
ether fe:ef:75:b3:45:15 txqueuelen 1000 (Ethernet)
RX packets 13 bytes 998 (998.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 17 bytes 1318 (1.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

This is my brctl show
bridge name bridge id STP enabled interfaces
lxcbr0 8000.00163e000000 no vethQAQT1O

This is my /etc/network/interfaces

The loopback network interface
auto lo
iface lo inet loopback

The primary network interface
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.202
netmask 255.255.255.0
gateway 192.168.1.254

This is an autoconfigured IPv6 interface
iface eth0 inet6 auto

This is the config of a container

lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:f5:fc:a9
lxc.rootfs = /var/lib/lxc/MATTINOCORRETTO/rootfs
lxc.rootfs.backend = dir

Common configuration

lxc.include = /usr/share/lxc/config/debian.common.conf

Container specific configuration

lxc.tty = 4
lxc.utsname = MATTINOCORRETTO
lxc.arch = amd64

Please, can someone give me an indication?

Thanks in advance


#2

For discovering the issue I would try to tcpdump the bridge on host to verify the DHCP packets are there, from client and answer from server.
You should check iptables for blocked traffic.


#3

Thanks for your reply.
If I put an Ip manually in the config file of container the network work well…
So my problem is that whe I create and start container, the container don’t take an ip address automatically…
any idea?


#4

It would help if you can add some text formating in the text, like

example

There are two pieces of information that are missing:

  1. Are you running these in a VM? If so, which?
  2. Which container image are you using? Stock or your own?