Newbie question: forward host DNS into container?

How can I make my LXD containers use my host’s DNS records in an “automatically updating” manner? Or is this already the case in the default lxdbr0 network?

I’m having trouble seeing a VPN DNS server inside the container, while on the host DNS is working properly. I may start and stop the VPN connection multiple times a day, meaning it would be nice to see the DNS change reflect inside the containers properly.

dnsmasq as run by LXD uses your /etc/resolv.conf so if that one is correct, things should work.

To clarify: dnsmasq uses the /etc/resolv.conf of the host? Or copies a new one into the container and uses that?

I had an issue where a subset of domains from an internal domain were accessible via DNS on the container, while some werent, though all of them were behind the same DNS server. Only after a container restart I could ping all hosts properly.

Container talks to dnsmasq on host over the network, dnsmasq on host reads /etc/resolv.conf and forwards queries there.

Your container may then itself be running resolved or dnsmasq that then do their own extra layer of caching and redirecting.

So it may be worth testing directly querying dnsmasq with host to see if that behaves when you hit issues.

Alright so disabling any addition DNS services should make the DNS setup auto-forward into a container. I’ll see if that is the case and report back.