No DNS resolution in chroot + qemu

Hi, I’m trying to chroot into a Raspbian image, but there’s not domain name resolution inside the chroot.

  • I’m 100% sure to have the correct bind mounts
  • the correct /etc/resolv.conf (i tried several)
  • ping an IP works (ipv4, ipv6)
  • I tried adding a domain in /etc/hosts, and resolution works for this domain only.
  • I tried using systemd-nspawn instead of chroot as it’s supposed to be more solid.

Still, I get :

root@latitude5400:~# ping google.com
ping: google.com: Temporary failure in name resolution

Do you have any idea ?
Thanks !

Hi and welcome to the forum :+1:

Check:

  • systemctl status systemd-resolved
  • resolvectl status

Thanks :smiley:

Here are the status :

~ ❯❯❯ resolvectl status
Failed to get global data: Unit dbus-org.freedesktop.resolve1.service not found.
~ ❯❯❯ systemctl status systemd-resolved
● systemd-resolved.service - Network Name Resolution
     Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; disabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: man:systemd-resolved.service(8)
             man:org.freedesktop.resolve1(5)
             https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
             https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients

Looks like none are used. That’s weird, I never customized the DNS config and I installed Manjaro less than 2 months ago.

Yea commands like ping need that service enabled (and started)…
But the service needs manual intervention for it’s correct operation maybe that’s why they didn’t enable it by default.
See: systemd-resolved.service

In short you just need to symbolic link /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf before starting it :wink:

Just to be sure : ping and such WORK in the host. They just don’t work in the chroot/systemd-nspawn “guest”.
I tried symlinking the resolv.conf and starting systemd-resolved, that did not help :frowning:

I have the exact same issue as @Salamandar: network and DNS work on host, only network works in chroot (DNS do not work).

I think the issue is that Manjaro uses NetworkManager and not resolvctl to handle DNS by default, whereas Raspian/Ubuntu uses resolvctl. I assume the incompatibility is causing the issue, but I haven’t found a solution yet.