Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I have 2 machines that switch back and forth between networks. One network has both configured in the DNS table, so that they can reach each other on that one. However, on the other network, they don't, but they will have static IP addresses there.

What I would like to do is configure both machines to FIRST query the DNS for an IP address when attempting to resolve a hostname, and, if that fails, THEN go to a static hosts file (i.e. /etc/hosts) to find an IP address for it. Can this be done, both on Win7 and Ubuntu?

share|improve this question
up vote 1 down vote accepted

What you want to do is change the hostname resolution order.

On Ubuntu, try looking in /etc/nsswitch.conf. There should be a line

hosts:    files dns

If you change that to

hosts:    dns files

it will try a DNS query first, and then go to /etc/hosts if the query fails.


On Windows, try changing the settings in


Change HostsPriority to be greater than DnsPriority (I'd recommend making it 2002).


share|improve this answer

You must log in to answer this question.

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