Help - How to enable DNS container name resolution using systemd-networkd and systemd-resolved

Hi all.

I apologize in advance for the general cluelessness. My goal is to enable container name resolution from my host server - currently I can only access containers via ip address. My setup looks like this:

  • Ubuntu Aardvark

  • LXD 2.21 running as a snap

  • LXD network configured as a bridge (lxdbr0 with ipv4.address:

  • Network configuration vi systemd-networkd and systemd-resolvd.

Would someone share a recipe for making this work. I’m not sure if this will require changes to dnsmasq or simply a systemd .network file that links lxdbr0 with the dns server

I’ve done a fair amount of googling, but the answers are all over the place and some of them obsolete.




In summary, you set up the host to also consult LXD’s DNS server (which knows about those .lxd hostnames).
Have a look at DNS for LXC containers.


Thanks much for the info and all of your contributions in the forum and blog posts. They’ve been most helpful!

I’m guessing that the above solution requires installing dnsmasq on the host machine. This seems to cause problems with systemd-resolved which doesn’t recognize the dnsmasq process. I have worked around this by configuring systemd-resolved to always use as the first nameserver, but that feels a bit like a hack.

The documentation on systemd-networkd and systemd-resolved are very sparse and incomplete.

Maybe I need to go back to NetworkManager or the old network interfaces systems.