I do not get IPV4 un container under LXD 4.18

What do I miss :

snap install lxd
lxd init

Would you like to create a new local network bridge? (yes/no) [default=yes]: no
Would you like to configure LXD to use an existing bridge or host interface? (yes/no) [default=no]: yes
Name of the existing bridge or host interface: eth0

lxc launch images:debian/bullseye debian
(wait 1 minute…)
lxc ls
±-------±--------±-----±--------------------------------------------±----------±----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
±-------±--------±-----±--------------------------------------------±----------±----------+
| debian | RUNNING | | 9999::ff:fe88:cd06 (eth0) | CONTAINER | 0 |
±-------±--------±-----±--------------------------------------------±----------±----------+

Working under old /etc/network/interface under last Raspberry OS :
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.163.1
netmask 255.255.255.0
gateway 192.168.163.254
network 192.168.163.0
broadcast 192.168.163.255
dns-nameservers 8.8.8.8 8.8.4.4

I use a local dhcp server which works fine with other clients. It may be the point…
Thanks for any help…

PC

Can you try lxc launch images:ubuntu/20.04 ubuntu just to see if it’s maybe a dhclient issue?

Thank you again. No more IP 4 address with ubuntu,
and no string “dhcp” in journalctl or in “ps aux | grep dh”

Ok, what does networkctl show you?

We’ve seen cases where specific NICs badly interact with macvlan unfortunately which can cause this kind of issue. It could also be an issue with the switch your machine is plugged into not letting multiple MAC addresses for the same physical port go through.

In the host :

root@sos:~# networkctl
WARNING: systemd-networkd is not running, output will be incomplete.

IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback n/a unmanaged
2 eth0 ether n/a unmanaged
3 wlan0 wlan n/a unmanaged

3 links listed.
root@sos:~# lxc exec ubuntu bash
root@ubuntu:~# networkctl
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
5 eth0 ether routable configuring

2 links listed.

The router is an old freebox, the host is a raspberry pi 4b, I see leases :
root@sos:~# systemctl status isc-dhcp-server.service
● isc-dhcp-server.service - LSB: DHCP server
Loaded: loaded (/etc/init.d/isc-dhcp-server; generated)
Active: failed (Result: exit-code) since Wed 2021-09-08 18:56:41 CEST; 5h 18min ago
Docs: man:systemd-sysv-generator(8)
Process: 659 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/isc-dhcp-server.service
└─694 /usr/sbin/dhcpd -4 -q -cf /etc/dhcp/dhcpd.conf

Sep 09 00:12:02 sos dhcpd[694]: DHCPOFFER on 192.168.163.62 to 00:16:3e:b8:43:41 (ubuntu) via eth0
Sep 09 00:13:05 sos dhcpd[694]: DHCPDISCOVER from 00:16:3e:b8:43:41 (ubuntu) via eth0
Sep 09 00:13:06 sos dhcpd[694]: DHCPOFFER on 192.168.163.62 to 00:16:3e:b8:43:41 (ubuntu) via eth0
Sep 09 00:13:42 sos dhcpd[694]: DHCPREQUEST for 192.168.163.60 from 94:be:46:11:54:13 via eth0
Sep 09 00:13:42 sos dhcpd[694]: Wrote 0 deleted host decls to leases file.
Sep 09 00:13:42 sos dhcpd[694]: Wrote 0 new dynamic host decls to leases file.
Sep 09 00:13:42 sos dhcpd[694]: Wrote 12 leases to leases file.
Sep 09 00:13:42 sos dhcpd[694]: DHCPACK on 192.168.163.60 to 94:be:46:11:54:13 via eth0
Sep 09 00:14:09 sos dhcpd[694]: DHCPDISCOVER from 00:16:3e:b8:43:41 (ubuntu) via eth0
Sep 09 00:14:10 sos dhcpd[694]: DHCPOFFER on 192.168.163.62 to 00:16:3e:b8:43:41 (ubuntu) via eth0

And :

cat /var/lib/dhcp/dhcpd.leases

lease 192.168.163.61 {
starts 3 2021/09/08 22:11:09;
ends 3 2021/09/08 22:13:09;
cltt 3 2021/09/08 22:11:09;
binding state free;
hardware ethernet 00:16:3e:88:cd:06;
uid “\377>\210\315\006\000\001\000\001(\313\252”\000\026>\210\315\006";
client-hostname “debian”;
}
lease 192.168.163.62 {
starts 3 2021/09/08 22:13:05;
ends 3 2021/09/08 22:15:05;
cltt 3 2021/09/08 22:13:05;
binding state free;
hardware ethernet 00:16:3e:b8:43:41;
uid “\001\000\026>\270CA”;
client-hostname “ubuntu”;
}

Thank you again !!!

If it’s not too much trouble, can you reconfigure your LXD host (rpi) to use a bridge instead of macvlan?

You’d effectively want to make sure that bridge-utils is installed and then change /etc/network/interfaces to something like (sorry been a while, not 100% sure it’s correct):

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
  address 192.168.163.1
  netmask 255.255.255.0
  gateway 192.168.163.254
  network 192.168.163.0
  broadcast 192.168.163.255
  dns-nameservers 8.8.8.8 8.8.4.4
  bridge-ports eth0

If this works, then you’ll get br0 which you can attach containers to and avoid the potential macvlan driver/kernel bugs.

Yes, I was about to try that. And please note that bridge-utils was soon installed - but not used - when I did previous tests.

Yes, it works by using bridge and replacing “macvlan” by “bridged” in the profile.
I am ready to test more macvlan if it helps…

Some question about using bridges : is this a workaround waiting some bug correction of macvlan ? or is it by design that in my case macvlan will “never” be the solution…?

macvlan should work in your case, but there are quite a lot of moving pieces outside of our control which can sometimes interfere. macvlan is dependent on the kernel driver for the physical NIC as well as in some cases the physical NIC itself supporting handling multiple MACs at the hardware level. As mentioned before, some switches also don’t enjoy it so much and may drop packets in one direction or another.

In your case, it looks like outgoing traffic is working fine but the NIC isn’t forwarding incoming traffic for some reason.

Bridges in general are far more reliable and the best option whenever possible.
macvlan is mostly a convenience as it doesn’t require a reconfiguration of the host networking to accommodate a bridge.

OK, I use bridge with lxd without any problem since years…
Thank you.
Encore !