After upgrade to Xubuntu 22.04, containers no longer get IPv4 addresses

Hey just adding my 2cents to this thread - and this is slightly off-topic because it pertains to Jammy containers not Jammy host - but its relevant I guess.

Today in the early afternoon, my Ubuntu Jammy 22.04 LXD DNS-DHCP container suddenly stopped getting DHCP ipv4 addresses (it had been working fine prior to the actual production release of Jammy, so maybe something happened when they rolled out Jammy GA - or maybe it is related to this New containers not getting ipv4 address (broken base images).

I tried the ufw steps that were suggested to get DHCP working inside Jammy containers, but it didn’t fix.

Then I took a look at /etc/netplan inside the Jammy container, and found the /etc/netplan directory for the vanilla just-installed jammy lxc container was totally empty. I did the following steps which fixed Ipv4 DHCP:

cd /etc/netplan

sudo vi 10-dhcp.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      dhcp6: false

sudo netplan apply

And now ipv4 DHCP is working perfectly inside the LXD Jammy container.

Also, I guess I will mention a slight tangent to this topic, but related: If you happen to end up using a netplan that uses the “gateway4” setting, note that “gateway4” syntax has been deprecated and has been replaced with new syntax as shown below:

gateway4: 192.168.10.1

replace with this syntax:

routes:
    - to: default
     via: 192.168.10.1