What is the order of name resolution on Linux?

IntermediateConceptDNS
Answer

Controlled by /etc/nsswitch.conf, usually hosts: files dns (or files resolve dns): first /etc/hosts, then DNS. Tools differ: getent hosts follows nsswitch like most applications, while dig and nslookup go straight to DNS and ignore /etc/hosts.

That difference explains "ping works but dig fails" situations.

All Networking questions Roadmap: Networking for DevOps

More on DNS