Solved

Get windows to use hosts before DNS

Posted on 2001-07-26
16
239 Views
Last Modified: 2008-02-20
How do I make windows look in a local hosts file before it queries DNS without third party add-on software?

Example hosts file (I had to go to dos prompt to get rid of the extension)

127.0.0.1      localhost
208.50.148.12   www.microsoft.com
10.1.2.3       www.foo.com

DNS resolution is set to the ISP's server.

when I type www.foo.com in my browser I see the local server OK. When I type www.microsoft.com I see M$'s server but I want to see EE's server which is the IP address in hosts file.

I can work around it by adding my own DNS server or using addons but that's not the Q. A reg tweak would be cool.


0
Comment
Question by:andyalder
  • 6
  • 5
  • 4
  • +1
16 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 6324050
Here you go. I just need to dig up which node type does what !!

http://www.winguides.com/registry/display.php/739/

I hope this helps !
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 6324075
Here
http://www.mcpmag.com/members/97novdec/col4main.asp

Isn't the internet grand !!

I hope this helps !
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 6324104
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 6324111
And finally - a better explanation at
http://ctdp.tripod.com/os/windows/wintcp/wtcpname.html
0
 
LVL 55

Author Comment

by:andyalder
ID: 6324125
Look Sys, get your web browser to go to www.experts-exchange.com when you type www.microsoft.com before you comment in this thread again please.
0
 
LVL 55

Author Comment

by:andyalder
ID: 6324453
I am going to delete this question and post it again with exactly the same wording and if some dork that does not know the difference between netbios and DNS f**ks it up again I'll quit EE.

>>Exchange is like a game. Some Experts play the game by providing a large quantity of poor answers.

same goes for comments in my book.

Hope this hepls.
0
 
LVL 41

Accepted Solution

by:
stevenlewis earned 300 total points
ID: 6324854
Andy, I am running ME here at the office, and I just edited my host file to read
208.50.148.12   www.microsoft.com

I then went to my browser and typed www.microsoft.com and it sent me to EE. (I will now have to edit it and reboot, LOL)
If you have been to M$ then you must clear the dns cache before it will resolve incorrectly.
I did my test on a fresh boot (no prior dns entries or resolution)
What OS are you testing this on?
And of course your hosts file is in c:\windows and just "hosts"? no extension
here is a link
http://www.daltontel.com/~dhack/mcse/tcpnameres.html
and here
http://www.phoneboy.com/faq/0072.html

and here is the definitive answer from M$
http://support.microsoft.com/support/kb/articles/Q172/2/18.asp
NOTE: In the context of this article, the term "client" does not necessarily refer to a workstation. A Windows NT server will take the role of client when it requires access to resources that require host name resolution.

Host name resolution generally uses the following sequence:


The client checks to see if the name queried is its own.


The client then searches a local Hosts file, a list of IP address and names stored on the local computer.

NOTE: The Hosts file location depends on the operating system:
   Windows NT                  %Systemroot%\System32\Drivers\Etc
   Windows 95                  <drive>\<Windows folder>
   Windows for Workgroups      <drive>\<Windows folder>
   Windows 3.1                 <drive>\<Windows folder>
   MS-Client 3.0               <Boot volume>\Net
   Lan Manager 2.2c Client     <Boot volume>\Net
Where %Systemroot% is the folder in which Windows NT is installed, <drive> is the drive on which the OS is installed, and <boot volume> refers to a boot floppy disk or drive C.

A sample hosts file, Hosts.sam, is installed with the TCP/IP protocol showing the proper format.


Domain Name System (DNS) servers are queried.


If the name is still not resolved, NetBIOS name resolution sequence is used as a backup. This order can be changed by configuring the NetBIOS node type of the client.


The Windows client will try each of these methods until it either successfully resolves the name or exhausts these methods. Windows NT, Windows 95, and Windows for Workgroups clients using Microsoft TCP/IP 3.11b follow this sequence. Lan Manager 2.2c or Microsoft Client 3.0 clients will not use NetBIOS name resolution as a backup
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 6324886
edit yours again, reboot, and see if it works for you
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 55

Author Comment

by:andyalder
ID: 6324947
It is nearly midnight, I'll try again tomorrow. Haven't tried ME, but it don't work with 95, 98 or nt4, sure you haven't got anything extra added?
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 6324975
positive, standard install
and again I point out the link from M$ in my above post
G'nite Andy
Steve
0
 
LVL 55

Author Comment

by:andyalder
ID: 6325020
>I did my test on a fresh boot (no prior dns entries or resolution)

Ah, "no prior DNS entries" but I have dns entry for the ISP's resolver in my config as I say in the question. Can you try again with a resolver configured.

0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 6325051
I will when I get home, as I have ip config info on my machine (dns entries)
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 6325398
OK Andy, I tried it at home (w98 se networked to my main, which is using ICS, so I have dns entries on my NIC. Two of them, one my main machine 192.168.0.1, and one is my isp. I made the entry to the hosts file, and it resolved it to here.
208.50.148.12   www.microsoft.com

so the question is why isn't your machine resolving from the hosts file first.
1.) you have the reg entries as mentioned in Sys's posts
2.) the hosts file is not configured correctly, so forgive me if I review the hosts file
must be named hosts, no extension (not .txt or .sam) just "hosts"
must be in c:\windows (if 9x) or %systemroot%\system32 (if NT/2000)
can not have the # pound sign in front of the entries
there must be at least one space between the ip address and the host name
Steve
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6326134
probably I may have not read some essential phrases in the long dialog above, but my  %systemroot%\system32\drivers\etc\hosts works if in the TCP/IP settings WINS tab the LMHOSTS query is enabled.
If you also need NetBIOS ther is a NetBIOS over TCP/IP checkbox too.
I never reboot when changing my hosts file (even this is a must for any change on M$ systems :), and also have never noticed any problems with cached mappings.

I also know that the TCP/IP nodetype should be set to hybrid (dezimal 7?) in the registry. You'll see the setting with the  ipconfig -all  command.

BTW, I do not "play the game by providing a large quantity of poor answers", I'm just wondering ...
0
 
LVL 55

Author Comment

by:andyalder
ID: 6326218
My apologies to sysexpert for being rude but it was nothing to do with netbios.
Following Steve's 2nd and 3rd URL led me to Q139270 and I see someone changed the registry keys to force DNS first.
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 6326238
Andy Glad we were able to get this all staighten out
Steve
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I've written instructions for one router type, but this principle may be useful for others of the same brand and even other brands of router. Problem: I had an issue especially with mobile devices that refused to use DNS information supplied via…
#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now