Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: hosts and lmhosts

19 Apr 2011   #31
colinearpsycho

7 home premium 64-bit
 
 

but why should i even do that, if the iterated process of hosts is to send addresses to a loopback point? if i use 127.0.0.1 google.com it will open. being that the address you give isn't google, why shouldn't it open? where is the variation, except that 127.0.0.1 is sending traffic back to a generic (like 168.192 or 192.168.x.x)... then again supposing someone is using a web server with that address on the network i just (presuming the address is bad) screwed them over. so it's like hot potatoe, and that's crap in terms of keeping a computer well maintenanced and configured. then if 127.0.0.1 is the only loopback point, it sounds more like you are saying in an office environment, you have a loopback point, don't deviate from that point in order to place our traffic into the sandbox and not screw people over. 0.0.0.0 makes sense as an alternate then, because insofar as i know there is no applicable web address for 0.0.0.0 (unless y2k was supposed to happen not because of numerical issues with time handling, but because some berkley genius didn't realize an important server was dedicated 0.0.0.0 when the protocol emerged).

i'm just saying that your example doesn't seem relevant in the same way that the hosts file is supposed to work where i can say, it's functioning because i can't look at the ip you gave and say, 'google' traffic was redirected there. did the website open then because i used 127.0.0.1 ? i don't understand that either, because my ip address is not 127.0.0.1 when i use cmd.exe to look it up with ipconfig. then again, it isn't the same when i use a live disc either. windows reports it as one number with ipconfig, and gentoo will report it as another number with ifconfig.

to fruther the discussion (if you want to call three pages on this topic that) would i then have to have a seperate machine to test if traffic is redirecting, or could i setup another disc and make it dedicated server space, and test it in that way? i'm not sure if you can 'fool' windows in that way, but i would presume because with 7 you can convert discs to dynamic although i guess that's flawed logic. I can't say whether the foolery is technically similar.

and i'm presuming by ::1 being present in the example that I can use ipv6 protocol addresses in the same way as tcp/ip/udp addresses are used respective to format?

so i suppose this is where confusion of a sort turns to frustration because i have to assume that Windows isn't (and i hope this is the correct term) enumerating internet address protocols correctly. otherwise, since my ip isn't the loopback point, i should have gotten an http error trying to direct traffic to the test entry. unless i had entered my ip in the test line, which i did not at that phase in trying to understand the hosts file function and process.


My System SpecsSystem Spec
.
19 Apr 2011   #32
colinearpsycho

7 home premium 64-bit
 
 

...make that 4 pages on the topic, it really isn't a bother to myself though...sorry if it's a nuissance on you..

i did try your example and i tried it in four ways:

googles ip
an odd ip (sorry odd ip it's just google)
my ip
and 127.0.0.1

the web browser did surf to google.com everytime. and i entered it in the address bar the exact same way it was listed in the hosts file. google.com. i used the hosts.file file, not lmhosts.sam because lmhosts is supposed to provide netbios names, and some functions regarding addresses to surf to from what i gather, and not traffic redirection.

as stated, if i enter an ip in the address bar it's producing google searches for that ip.

as a side note, can i enter addresses as http:// or https:// or ftp:// etc? or does a working hosts file strictly rely on a simple format of ya.da.com or yada.com; etc. does that syntactic form have a name like there is pnrp?
My System SpecsSystem Spec
19 Apr 2011   #33
logicearth

Windows 10 Pro (x64)
 
 

Do you even know what it is you are trying to do, colinearpsycho?
Because, right now this thread is nothing but a waste of time.
My System SpecsSystem Spec
.

20 Apr 2011   #34
pparks1

Windows 7 Ultimate x64
 
 

Quote   Quote: Originally Posted by colinearpsycho View Post
i did try your example and i tried it in four ways:

googles ip
an odd ip (sorry odd ip it's just google)
my ip
and 127.0.0.1

the web browser did surf to google.com everytime. and i entered it in the address bar the exact same way it was listed in the hosts file. google.com. i used the hosts.file file,
Well, you MUST be doing something wrong. This is a fundamental process. it's as easy as 1+1=2.
And the file is simply hosts....not hosts.file

Do, these steps exactly like this;
Run command prompt as administrator.
Code:
notepad C:\windows\system32\drivers\etc\hosts
Ensure it looks like this;
Code:
# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
127.0.0.1        www.google.com
Then, from command line, run ping Google. Your results should be exactly like this;
Code:
C:\Windows\system32>ping www.google.com

Pinging www.google.com [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

And it should be noted that you have to try hitting www and then the .google.com.   If you simply put google.com...well that's a different name and it will resolve using DNS to the right thing as shown;

Quote:
C:\Windows\system32>ping google.com Pinging google.com [74.125.225.17] with 32 bytes of data: Reply from 74.125.225.17: bytes=32 time=63ms TTL=55 Reply from 74.125.225.17: bytes=32 time=61ms TTL=55 Reply from 74.125.225.17: bytes=32 time=64ms TTL=55 Reply from 74.125.225.17: bytes=32 time=64ms TTL=55 Ping statistics for 74.125.225.17: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 61ms, Maximum = 64ms, Average = 63ms C:\Windows\system32>
Now, if you put a line in C:\Windows\system32\drivers\etc\hosts as follows, it would then work;
Code:
#    127.0.0.1       localhost
#    ::1             localhost
127.0.0.1        www.google.com
127.0.0.2        google.com
172.16.10.1        www.wackyexample.com
Watch what happens
Quote:
C:\Windows\system32>ping www.google.com Pinging www.google.com [127.0.0.1] with 32 bytes of data: Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Ping statistics for 127.0.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\Windows\system32>ping google.com Pinging google.com [127.0.0.2] with 32 bytes of data: Reply from 127.0.0.2: bytes=32 time<1ms TTL=128 Reply from 127.0.0.2: bytes=32 time<1ms TTL=128 Reply from 127.0.0.2: bytes=32 time<1ms TTL=128 Reply from 127.0.0.2: bytes=32 time<1ms TTL=128 Ping statistics for 127.0.0.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\Windows\system32>ping www.wackyexample.com Pinging www.wackyexample.com [172.16.10.1] with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out. Ping statistics for 172.16.10.1: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), C:\Windows\system32>
Now, if I change up the hosts file to read differently, look at new results;
Code:
# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
1.1.1.1        www.google.com
1.1.2.1        google.com
1.1.3.1        www.wackyexample.whattheheck.com

C:\Windows\system32>ping www.google.com

Pinging www.google.com [1.1.1.1] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 1.1.1.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Windows\system32>ping google.com

Pinging google.com [1.1.2.1] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 1.1.2.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Windows\system32>ping www.wackyexample.whattheheck.com

Pinging www.wackyexample.whattheheck.com [1.1.3.1] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 1.1.3.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Windows\system32>
C:\Windows\system32>
Finally, if you open IE and type in
Code:
http://www.google.com
You should get a page cannot be displayed error page


Now, watch what happens as I adjust host file entries;

Code:
# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
1.1.1.1        www.google.com
1.1.2.1        google.com
1.1.3.1        www.wackyexample.whattheheck.com


C:\Windows\system32>ping www.google.com

Pinging www.google.com [1.1.1.1] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 1.1.1.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Windows\system32>ping google.com

Pinging google.com [1.1.2.1] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 1.1.2.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Windows\system32>ping www.wackyexample.whattheheck.com

Pinging www.wackyexample.whattheheck.com [1.1.3.1] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 1.1.3.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Windows\system32>


Yeah, I'm throwing in the towel in this thread. I do computer systems admin stuff for a living. I manage windows servers and Linux servers and have been doing so for 12+ years. I run some of the DNS servers in our shop and have a fair amount of experience with networking overall. I cannot for the life of me, even determine what the OP is trying to accomplish or what they are doing.
My System SpecsSystem Spec
20 Apr 2011   #35
colinearpsycho

7 home premium 64-bit
 
 

what's an OP? and i told you i performed those steps, they aren't working. apparently one or two of you fellers could use some time away from the terminal.
My System SpecsSystem Spec
20 Apr 2011   #36
logicearth

Windows 10 Pro (x64)
 
 

OP in this context means, Original Poster, you colinearpsycho.
My System SpecsSystem Spec
20 Apr 2011   #37
colinearpsycho

7 home premium 64-bit
 
 
....

ok thanks for that information. yeah i realize i'm trialing parks patience and you might not see the logic in my asking in conversation versus reading the knowledge bases. to say it readily, the idea of tutoring someone on the topic just isn't straight forward through the internet; while i can find a tutorial, it isn't going to make me understand concretely which ip to use, or why the file is not acting according to the way that it is described in literature as as it has been described here. the simple fact for me is that it is not. i think i've put it pretty plainly, i'm not sure how expertise could alude to unclarity in explaining the issue so that i can resolve it; meaning the trouble doesn't seem amateurish as i've tried the proper syntax. so it only seems fit that i should ask someone knowledgeable, and then again if the entire trouble i'm experiencing with name resolution and/or hosts is more than just understanding the file structure of a hosts file, then it doesn't make sense to surf the internet trying to find the answer. maybe it's rude to post on a forum expericing a possible computer error, but stopping me short of i'm better than you isn't resolving a damn thing. hate to sound like a highlander who has lived in texas for twenty years, but i'd like to understand why the file isn't functioning. and the only two possible answers i can come up with, or three if you want to be concise, is that either dns just isn't resolving properly, there is a default document on the network providing redirection to newly addressed websites when a hosts entry is made (i'm not sure if that differs from a hijacking it seems more like a bypass), or there is a peripheral or interface error that is causing the trouble as an underlying factor, making the hosts file obselete (which is why i said it sounds like goto statement harmful).

i'd just like to resolve the trouble, and learn from the issue. reloading the operating system time and again for errors i might be able to solve is not productive. the entire idea behind maintaining a forum i think, and i apologize again if this is rude to you gurus, is that it is productive and ducking out the back oin the OP like this were an mmo duel is ridiculous. if that's the case, why respond? even more still, i don't intend to produce a reality ... script.... (show) and i don't see why forums for technical problem solving seem to reduce themselves to conflicts over RTFM. acquisition of and effective use of human correspondance is as a fact faster and more productive when dealing with i/o systems. i'm just trying to procure some more learned advice for myself on the matter. i'll recap again, but i'm not trying to draw out the resolution of the issues placed forth in this post:

-the hosts file syntax is correct
- i understand the function of hosts and lmhosts
- redirection function of the hosts file is somehow being thwarted

that seems to be where the resolution process has arrived.
My System SpecsSystem Spec
20 Apr 2011   #38
pparks1

Windows 7 Ultimate x64
 
 

Quote   Quote: Originally Posted by colinearpsycho View Post
- redirection function of the hosts file is somehow being thwarted

that seems to be where the resolution process has arrived.
Yes, this must be the case. Perhaps you have some malware or something else on your machine that is preventing the HOSTS file proper working. I work with hosts files every single day at work in a lab where we don't have DNS in place and I can guarantee you that what I am showing is the way that it's supposed to work.

1. Did you by any chance apply a system tweak that prevented your computer from using the HOSTS file?
2. And when you do make changes to C:\windows\system32\drivers\etc\hosts you are SAVING the file before testing, right?


Code:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>notepad C:\windows\system32\drivers\etc\hosts


# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
192.168.1.1        www.google.com
192.168.1.2        www.sevenforums.com
Now, the results of a ping should come back as follows; Notice that the replies are from my router (192.168.1.1) and from my file server (192.168.1.2). These replies are NOT from the legitimate web servers which host either Google or Sevenforums. If I attempted to hit either of these pages with my web browser, they would NOT come up as the web server code for Google and Sevenforums is NOT running on either my router (192.168.1.1) or my file server (192.168.1.2).

Code:
C:\Windows\system32>ping www.google.com

Pinging www.google.com [192.168.1.1] with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time=4ms TTL=64
Reply from 192.168.1.1: bytes=32 time=4ms TTL=64
Reply from 192.168.1.1: bytes=32 time=4ms TTL=64
Reply from 192.168.1.1: bytes=32 time=5ms TTL=64

Ping statistics for 192.168.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 4ms, Maximum = 5ms, Average = 4ms

C:\Windows\system32>ping www.sevenforums.com

Pinging www.sevenforums.com [192.168.1.2] with 32 bytes of data:
Reply from 192.168.1.2: bytes=32 time=4ms TTL=128
Reply from 192.168.1.2: bytes=32 time=4ms TTL=128
Reply from 192.168.1.2: bytes=32 time=4ms TTL=128
Reply from 192.168.1.2: bytes=32 time=4ms TTL=128

Ping statistics for 192.168.1.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 4ms, Maximum = 4ms, Average = 4ms

C:\Windows\system32>
If you deleted the lines (or comment them out) in C:\windows\system32\drivers\etc\hosts, you should get the following legitimate addresses back from DNS as shown.
Code:
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
#192.168.1.1        www.google.com
#192.168.1.2        www.sevenforums.com

C:\Windows\system32>ping www.google.com

Pinging www.l.google.com [74.125.225.16] with 32 bytes of data:
Reply from 74.125.225.16: bytes=32 time=62ms TTL=55
Reply from 74.125.225.16: bytes=32 time=65ms TTL=55
Reply from 74.125.225.16: bytes=32 time=64ms TTL=55
Reply from 74.125.225.16: bytes=32 time=64ms TTL=55

Ping statistics for 74.125.225.16:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 62ms, Maximum = 65ms, Average = 63ms

C:\Windows\system32>ping www.sevenforums.com

Pinging sevenforums.com [74.86.171.210] with 32 bytes of data:
Reply from 74.86.171.210: bytes=32 time=46ms TTL=113
Reply from 74.86.171.210: bytes=32 time=42ms TTL=113
Reply from 74.86.171.210: bytes=32 time=41ms TTL=113
Reply from 74.86.171.210: bytes=32 time=43ms TTL=113

Ping statistics for 74.86.171.210:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 41ms, Maximum = 46ms, Average = 43ms

C:\Windows\system32>
Now, if you want to see what DNS says the proper addresses are, you can use nslookup from command line as shown below; (note: you can also see that sevenforums has a legitiate ipv6 address )

Code:
C:\Windows\system32>nslookup
Default Server:  vnsc-bak.sys.gtei.net
Address:  4.2.2.2

> www.google.com
Server:  vnsc-bak.sys.gtei.net
Address:  4.2.2.2

Non-authoritative answer:
Name:    www.l.google.com
Addresses:  74.125.225.17
          74.125.225.18
          74.125.225.19
          74.125.225.20
          74.125.225.16
Aliases:  www.google.com

> www.sevenforums.com
Server:  vnsc-bak.sys.gtei.net
Address:  4.2.2.2

Non-authoritative answer:
Name:    sevenforums.com
Addresses:  2607:f0d0:1003:7b::2
          74.86.171.210
Aliases:  www.sevenforums.com
I really hope this helps.
My System SpecsSystem Spec
21 Apr 2011   #39
colinearpsycho

7 home premium 64-bit
 
 
alas

the syntax for hosts is

loopback friendly name resolution for the domain domain ip

that syntax is working sufficiently to block redirection to webpages. when i entered bleeping copmuter, (which i had made a few entries previously) MSE found and removed a hosts hijacker.

this is how i have lmhosts structured, the example is unclear and the terminology has me at odds.

site ip friendly name resolution #includes

i'm sure that format is working, at least it's what the file says to us, but i don't understand the #Include \\file. Does this cause lmhosts to query another file, run it as a script/batch, or start a program?
#Include C:\Windows\System32\drivers\etc\hosts
My System SpecsSystem Spec
21 Apr 2011   #40
logicearth

Windows 10 Pro (x64)
 
 

Leave lmhosts alone.
My System SpecsSystem Spec
Reply

 hosts and lmhosts




Thread Tools




Similar help and support threads
Thread Forum
Hosts file ignored and replaced with hosts.original
Hello. I am trying to use the hosts file. However both pings and web addresses still bypass the hosts file. I noticed that there is another file in the C:\Windows\System32\drivers\etc directory called 'hosts.original'. When ever I delete this file, it reappears seconds later. I have made sure that...
General Discussion
Hosts.txt or hosts.sys
in the drivers/etc folder is: hosts.txt and hosts.sys. I want to edit the hosts file but i dont know is it hosts.txt Or hosts.sys. Oh, theres a file called Hosts without extension on my diffrent pc too. Can you tell me is it safe to edit hosts file as well? The hosts file witout extension...
General Discussion
Hosts file-S??
can the hosts file be changed to, or amended by, another file? IOW can there be a file named xyz that essentially replaces the hosts file, or adds entries to it? Possibly by a registry key or configuration setting? Of course it could by altering library fxns, but by other "simpler" means? ...
System Security
hosts...again...but differed
i put some of the network computers on my hosts list, to try and circumvent some issues and lost internet connectivity. none of the ip addresses are listed as the subnet, default gateway; etc. they were just ip's of other computers that connect to this network at times. why did that happen? is it...
Network & Sharing
HOSTS File - Create a "Edit HOSTS file" Shortcut
How to Create a "Edit HOSTS file" Shortcut in Windows 7 and Vista The HOSTS file is a .txt file used in Vista and Windows 7 to map hostnames to IP addresses. Your computer checks this file first to resolve any network names to its corresponding IP address before it tries to check the Internet....
Tutorials
HOSTS file
I setup a hosts file in windows xp in order to use my website locally using the exact domain name by editing the hosts file by adding the line: 127.0.0.1 www.test.com This should resolve my local ip address for the test.com site and if apache is running, then it should load the website...
Network & Sharing


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:43.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App