Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

/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 (127.0.0.1), 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

share|improve this answer

Your Answer

 
discard

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.