Where Is Linux Name Resolution Order Configured?
Name resolution order lives in nsswitch.conf, deciding when files, DNS, and directory services answer.
Last updated
The name service switch config decides lookup order for hosts, users, groups, and more. Each line names sources in priority order: local files, DNS, directory services, and fallbacks.
That ordering explains resolution mysteries completely. Correct DNS with a wrong hosts entry loses when files come first; LDAP users vanish when the directory source drops out of line. Read this file before touching any resolver, since it governs them all.
Where Linux stores this, by platform
/etc/nsswitch.conf
Lookup order for hosts, users, and groups as plain text. Reorder sources here to fix whole classes of resolution bugs; every lookup obeys it.
Frequently asked questions
Hostnames resolve wrong despite correct DNS. Where do I look?
Reorder the hosts line so files comes before DNS, or add the directory service in the right slot. Every lookup follows this order, so one line fixes whole classes of resolution bugs.
Notice an outdated path? Let us know.