Linux – Difference between /etc/hosts and /etc/resolv.conf

domain-name-systeminternal-dnslinuxlinux-networkingnetworking

What is the difference between /etc/hosts and /etc/resolv.conf? Also, is there a good documentation that explain all these configuration files.

Thank you.
Bala

Best Answer

resolv.conf specifies the nameservers for resolver lookups, where it will actually use the DNS protocol for resolving the hostnames.
Typically the hosts file is used for administrative purposes, such as backend and internal functions, which is substantially more isolated in scope, as only the local server will reference it.

/etc/nsswitch.conf specifies the lookup order with the hosts entry.

If this does not answer your question, please clarify further.

Look at the following manpages:

HOSTS(5)  
RESOLVER(5)