Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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.

(source: https://help.ubuntu.com/10.04/serverguide/network-configuration.html)

On Windows, try changing the settings in

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\ServiceProvider

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

(source: http://www.speedguide.net/articles/host-resolution-priority-tweak-1130)

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.