943714 wrote:Correct. nslookup only checks your configured nameservers (in /etc/resolv.conf) not your local /etc/hosts file. It's not designed to do that. If you want to query your local /etc/hosts file, you should use getent instead.
nslookup would not check against /etc/hosts, the file gets ignored.
943714 wrote:That depends on the application. If it's written properly, it will check the order in /etc/nsswitch.conf and resolve names appropriately. You would need to test using the target application.
Okay. But what if I don't have DNS access, and meanwhile an anpplication needs to get a host name resolved? I would have to add the entry in /etc/hosts right the way. By adding the entry in /etc/hosts, should the application be able to resolve the name? does an application usually resolve a host name by checking /etc/hosts or dns entries
Dude wrote:This is not true: The only way to configure a DNS server is to add the IP address of the server as a nameserver entry in /etc/resolv.conf on a Linux machine. There is no need to add anything to /etc/hosts.
In order for your system to find a DNS server you need to add an entry in the /etc/hosts file, e.g. dnsserver1 -> 192.168.1.53, or address the nameserver directly using the IP address. A DNS server can also be installed and queried on the local machine.
Soundar wrote:Of course it's possible. Offhand, I'm pretty certain that's exactly what gethostbyname() and getipnodebyname() do - go through /etc/nsswitch.conf and query the proper data store(s).
ideally i should have replid for actual poster, hosts file is alternate option for DNS which works within host only, IP and host name can be update in hosts file wherever we don't have DNS server as resolver.
i assume he is trying to use hosts file from some application which may not be possible, if we get full scenario can look out.