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.
More on DNS
What does DNS do and what happens when you type a URL into a browser?BeginnerWhat are the common DNS record types?BeginnerWhat is the difference between a recursive resolver and an authoritative server?IntermediateExplain the DNS resolution chain step by step with dig.IntermediateWhat is TTL in DNS and how does it affect changes?BeginnerWhat is negative caching in DNS?Intermediate