Suppose that /etc/nsswitch.conf file contains

hosts: files dns

and /etc/host.conf file has

order bind,hosts

then in which order the system would use /etc/hosts and DNS look-up to resolve a host name? In other words, which of the two configuration files takes precedence?

1 Answer 1


/etc/nsswitch.conf is the default file for domain name resolution these days. I have the following line at the top of my /etc/host.conf file:-

# The "order" line is only used by old versions of the C library.

nsswitch.conf is used by pretty much everything on my Debian box for name resolution. So, given the above lines in your files, the default name resolution order would be to check /etc/hosts first, and then use the nameservers configured in /etc/resolv.conf to do a DNS lookup.

Lately (since about Ubuntu 11.10), the /etc/resolv.conf is by default configured to use the localhost interface (, where a daemon program dnsmasq listens on port 53 for DNS requests. This in turn usually does DNS resolution as configured by your LAN's DHCP server, but this can be manually overridden in the OS's network configuration GUI.

Note: You didn't mention what OS you are using, and the above is coming from personal experience with Debian Ubuntu. The defaults might be different on different flavours of Linux

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .