I'm currently working on a project that has required some DNS troubleshooting. However I am fairly new to the wonderful world of networking and I'm at a bit of a loss as to where to begin.

My specific problem probably belongs on the Raspberry Pi Stack Exchange, so I'll avoid crossposting. Just looking for information here.

Looking for information, I was lead to the resolv.conf(5) file, resolvconf(8), systemd-resolve(1), and the beast that avahi appears to be.

My Raspberry Pi with Raspbian Buster appears to have avahi-daemon running.

My Ubuntu 18.04.4 LTS has systemd-resolved AND avahi-daemon.

Does resolvconf(8) (man page only on Ubuntu) coordinate the two?

When is /etc/resolv.conf used/ignored?

On Ubuntu:

$ cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

search telus

On Raspbian:

$ cat /etc/resolv.conf

# Generated by resolvconf
nameserver fd51:42f8:caae:d92e::1

Which utilities are responsible for this?

I don't really understand enough jargon to sift through the man pages and differentiate all these, and I'd love an explanation of how their roles are related.

1 Answer 1


When you run a command such as ping foobar the system needs to work out how to convert foobar to an ip address.

Typically the first place it looks is /etc/nsswitch.conf.

This might have a line such as:

hosts:          files dns mdns4

This tells the lookup routine to first look in "files", which is /etc/hosts. If that doesn't find a match then it will then try to do a DNS lookup. And if we still don't know the answer then it'll try to do a mDNS lookup.

The DNS lookup is where the system then looks at /etc/resolv.conf. This tells it what DNS servers to look at. On my machines I have this auto-configured by DHCP.

% cat /etc/resolv.conf 
# Generated by NetworkManager
search mydomain

How resolv.conf is built can change, depending on the operating system, what optional components you got, other configuration entries, boot sequence... In your case, on Ubuntu, you're running the systemd programs that configure this file to point to your local systemd-resolved and that will know how to talk to the real DNS servers.

On my primary servers, which have static IP addresses and no systemd-resolved, I manually edit this file.

Finally mdns4 tells the routines to try asking avahi-daemon if it knows the name.

You can change the rules. eg if /etc/nsswitch.conf just said:

hosts: files

then only the local /etc/hosts file is used.

Other entries are possible; eg ldap would make it do an LDAP lookup.

  • 5
    The /etc/resolv.conf file is just an implementation detail, it is not as essential as this answer implies. The definitive mechanism for applications to do name resolution is via library functions. These functions can make use of resolv.conf or they may not. Depending on how it is configured, systemd-resolved can make use of an existing resolv.conf provided by e.g. resolvconf(8), or it can optionally provide /etc/resolv.conf via a symlink to a systemd-resolved maintained version of the file. See freedesktop.org/software/systemd/man/… Commented Jul 3, 2020 at 4:49
  • Everything is "implementation detail" if you go deep enough. For example, nsswitch.conf is a libc feature and alternate libc libraries need follow this. I described how glibc and the attendent NSS libraries work. Ubuntu and Debian, out of box, do as I describe. Commented Jul 3, 2020 at 11:21
  • 6
    @StephenHarris What about resolvconf?
    – Déjà vu
    Commented Aug 26, 2021 at 6:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .