Interview Prep/Linux/Networking, SSH & Scheduling

What are /etc/hosts, /etc/resolv.conf and /etc/nsswitch.conf?

IntermediateConceptNetworking, SSH & Scheduling
Answer
  • /etc/hosts: static name to IP map.
  • /etc/resolv.conf: DNS servers (nameserver), search domains, options like ndots, timeout.
  • /etc/nsswitch.conf: lookup order, e.g. hosts: files dns.

On systemd-resolved systems /etc/resolv.conf is a symlink to a stub (127.0.0.53); see the real upstreams with resolvectl status. dig reads resolv.conf directly and skips /etc/hosts; getent hosts name follows nsswitch like applications do.

All Linux questions Roadmap: Linux

More on Networking, SSH & Scheduling