I don't have a scenario. What I thought was this: when any application attempts to resolve a name, a.example.com, it will look for /etc/hosts first, then if it could not find any entry to match, then look for DNS based on the setting in /etc/nsswitch.conf: hosts: file dns. In this way, I can manually put an entry in /etc/hosts, if there is no such line in DNS. I understand /etc/hosts only works on local machine.
So, if I could not immeidately update DNS, and also /etc/hosts get ignored, then how application could resolve a host name or ip address. That is why I got confused.
The standard behavior of internet applications and tools is to use /etc/hosts file before attempting to resolve a name or IP using DNS. This can be changed in /etc/nsswitch.conf. Unless you use tools, like nslookup or host, which were specifically designed to only query DNS and ignore /etc/hosts by design.
Again, /etc/hosts file is not DNS . The hosts file provides name resolving for a host, but not a internet network domain, like example.com. So in order to specifically query the /etc/hosts file under Linux you have use the getent utility as previously mentioned. For instance:
Applications use a resolver library to determine the IP address associated with a host name. The usual suspects use "/etc/nsswitch.conf" to determine what resources to query, and in what order.
Why do you think your */etc/hosts* file is being ignored?
<li>Show us how you did your test.
<li>Please show us your */etc/hosts* file.
<li>Please show us your */etc/nsswitch.conf* file; at least the hosts: entry.
<li>Please show us your */etc/resolv.conf* file.
<li>Are you running dnsmasq(8) locally? If so, we need to see your */etc/dnsmasq.conf* files. This is a commonly-used DNS acceleration tool.