Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 9 down vote accepted

resolv.conf specifies the nameservers for resolver lookups, where it will actual 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 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:


share|improve this answer

resolv.conf specifies nameservers in order of search preference.

hosts overrides all nameservers by mapping urls/shortnames to IPs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.