Problem with DNS resolution within a container

Hi,
I run LXD 5.21 on Ubuntu 24.04. Everything is as simple as possible: the server has one Ethernet interface configured for DHCP. DNS resolving works well on the server.
I’ve created a Debian 12 container instance from my image that is configured for ifupdown instead of systemd-networkd. Unfortunately the DNS resolving doesn’t work:

lxc exec tst3 -- ping yahoo.com
ping: yahoo.com: Temporary failure in name resolution

I have never had any issues with this image on LXD 3.0.3 on Ubuntu 18.04.
In the past, the /run/systemd/resolve/stub-resolv.conf was generated as the following, and resolving worked well:

domain lxd
search lxd
nameserver <IP of lxdbr0>

In Ubuntu 24.04/LXD 5.21 the /run/systemd/resolve/stub-resolv.conf is generated differently:

nameserver 127.0.0.53
options edns0 trust-ad
search  .

and the resolving doesn’t work:

ping yahoo.com
ping: yahoo.com: Temporary failure in name resolution

It is possible to define a DNS server statically in resolv.conf, but then it will be problematic to move the container to another server.

The debian12 container from images.lxd.canonical.com is configured for systemd-networkd and doesn’t have the resolving problem. However, I would like to use the same image for creating containers in LXD 3.0.3 and also on LXD 5.21. The systemd-networkd doesn’t work on old systems…
Any help is appreciated.

Leonid

Where is the DNS configuration in your container? Please can you show me the configuration files your older image is using?

Thanks

Hello Thomas,
Eventually, I uninstalled the systemd-resolved package in my custom Debian 12 LXD image and it solved the problem. Now LXD creates /etc/resolv.conf

domain lxd
search lxd
nameserver 10.144.113.1

when the container is created and the resolving works well.
In contrast, when the systemd-resolved is installed, the /etc/resolv.conf is a symbolic link to /run/systemd/resolve/stub-resolv.conf that contains:

nameserver 127.0.0.53
options edns0 trust-ad
search  .

Such configuration works well when system-networkd is used. But in my custom image, I use ifupdown because of reasons. And then the resolving doesn’t work. As a workaround, I uninstalled the systemd-resolved package and the problem was solved.
Thank you.