Solved

hosts entries priority, ignored if not 127.0.0.1

Posted on 2004-09-06
23
379 Views
Last Modified: 2010-04-13

Perhaps the title is not the best explanation... but basically the problem I do have is with the hosts file in a windows 2000 professional SP4 up to date of hotfixes.

I'm developing a website, and before I do finish the site and do a DNS change, I do want to test the site's script behaivor...
Basically what I'm doing is to change the IP address entry in the hosts file of the current site name to point to my new server where all the test files reside.

If I do open a console and ping www.mysite.com, it resolves to the address I have put into hosts file, but if I do load the browser, it seems to ignore the hosts entry and loads the onld server site. I have done a ipconfig /flushdns, and still sme.

It only seems to act as expected if I do use 127.0.0.1 address in host file (however my server is not in localhost)...

Perhaps this is some kind of anti-hijacking of domains?...
Thanks for your help!
0
Comment
Question by:demienx
  • 13
  • 5
  • 4
  • +1
23 Comments
 
LVL 32

Accepted Solution

by:
Luc Franken earned 500 total points
ID: 11992167
Hi demienx,

Are you connected through some kind of proxy? If so, your hosts file might be ignored.

Greetings,

LucF
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 11992168
have you cleared the IE cache

and run a

ipconfig /flushdns

command?
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 11992185
luc raises a valid point :)

if you are using a proxy
in IE click tools >internet options >connections >LAN settings
ensure bypass proxy for local addresses is ticked

in IE click tools >internet options >connections >LAN settings >advanced
in the bypass proxy for addresses begining with

put in mysite.com

stop and retart IE
0
 

Author Comment

by:demienx
ID: 11992562
I do connect to the internet thru an ADSL router with NAT.

I have tried deleting the cache, using firefox, and even offbyone browser...

The settings on hosts file are taken in consideration when the address is 127.0.0.1, but when I do point to the new server ip address, is just ignored, and used the current dns holder ones.

So, in some way hosts file is readed and used for resolve the domain name, but if is not the localhost one, just ignored.

If I do use 127.0.0.2, I can see i.e. status bar message saying... connecting to 127.0.0.2 and then the "The page cannot be displayed" message...

Is that perhaps that a negative reply for the server holding the used ip is causing the dns system to contact the dns server instead just using the hosts file entry??

weirdo...
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 11992600
127.0.0.2 ???

all 127 range is reserved for testing?

are you sure your host file doesnt have an extension on it? it should have none

your host file is ALLWAYS parsed before DNS and AFTER the internal resolver cache
0
 

Author Comment

by:demienx
ID: 11992674
For a clear example:

If I do add:

213.4.130.210 www.hotmail.com

It still loads hotmail page. If I do use 127.0.0.1 www.hotmail.com it does not...

(213.4.130.210 belongs to terra.es)


0
 

Author Comment

by:demienx
ID: 11992677

Even if I do clear the cache, do ipconfig/flsuhdns, or reboot the computer...

Will try in my other os to see what happens...
0
 
LVL 32

Expert Comment

by:Luc Franken
ID: 11992683
Hmm... very strange, just as a test, I added the same line, and hotmail.com directed me instantly to terra.es (don't know what that site's about, but it sure looks good :o) )
0
 

Author Comment

by:demienx
ID: 11992790

Just done the testings...

Tried in another clean but up to date win2k pro SP4, and still the sme problem...

Then tried in a windows Millenium installation, and still the same...

Finally I have tried using a dialup connection instead of my adsl connectio with another ISP, and it works!!!

What this makes me think that... or this is related to my ADSL ISP, to the Zyxel router I'm using, or perhaps the routing tables and metrics as when in ADSL, I use default getaway and DNS setting on the OS box, when using dialup, a new network is created the the routing tables change...

Any ideas about the router settings perhaps?
0
 

Author Comment

by:demienx
ID: 11995514

I just asked a friend that has windowsXP and a cable modem, and happens the same.

Someone there with adsl connection using NAT can tell me if gets the same?
thx
0
 
LVL 32

Expert Comment

by:Luc Franken
ID: 11997977
I'm using ADSL and NAT, and it's fine here, but I don't have a ADSL modem directly connected to my computer, one router and a firewall are inbetween.
Could be that the driver of your modem ignores the Hosts file for some addresses (not local) and rather uses it's own DNS.

LucF
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:demienx
ID: 11998143

I don't use a modem either.. I do use an ADSL router. I noticed that it has RIP-1 enabled in both directions...
I'll try switching this settings...

0
 

Expert Comment

by:Bionicthumb2
ID: 11998429
Are you sure the Hosts file is called "HOSTS" and not "HOSTS.SAM", "HOSTS.SAM.TXT", etc.
The Hosts file should not have a file extension.

Try going to the command prompt and typing ...
        ipconfig /flushdns & ipconfig /displaydns <ENTER>

Do the domain names in question have a TTL (Time to Live) value of 0?
0
 

Author Comment

by:demienx
ID: 12004624

The hosts file is as it should be, no extensions and is located at C:\WINNT\system32\drivers\etc\hosts of my win2k pro system.

As for example, if I do assign the i.p. from www.terra.es (213.4.130.210) to www.hotmail.com in the hosts file,
and then I do ping to www.hotmail.com, the ping resolves to address 213.4.130.210. So apparently it is doing ok.

But if I do load in the browser, it does go to www.hotmail.com. (tried in 3 different computers). It only works, if I do unplug
my network cable and do a dialup connection. Then, with my dial-up I do type www.hotmail.com and it takes me to www.terra.es site...

If I do ipconfig /flushdns & ipconfig /displaydns, that's what I do get:

 www.hotmail.com.
 ------------------------------------------------------
   Record Name . . . . . : www.hotmail.com
   Record Type . . . . . : 1
   Time To Live  . . . . : 31533380
   Data Length . . . . . : 4
   Section . . . . . . . : Answer
   A (Host) Record . . . :
                     213.4.130.210
0
 

Author Comment

by:demienx
ID: 12004658

The hosts file is being interpreted when I'm connected to internet with the ADSL router (NAT) withinmy LAN.

If I do add

192.168.0.200      www.hotmail.com

Then I launch the browser and sends me to my local web browser.
But if I do

213.4.130.210      www.hotmail.com

It does send me to hotmail.com, unless I'm on dialup. Then it does send me to terra.es

So you see? the problem is when I'm connection to internet thru my router AND the address in the host file is not a local one...

0
 

Author Comment

by:demienx
ID: 12004752
I have also trie to stop the DNS Client service, and still happens the same...

this is driving me mad   }:^ P

0
 
LVL 32

Expert Comment

by:Luc Franken
ID: 12007163
Just a wild guess... have you used or are you using ICS? If so, check if you can find a hosts.ics in the same folder as your normal hosts file, insert the lines there and check if it helps.

LucF
0
 

Author Comment

by:demienx
ID: 12022913

I'm not using I.C.S....

If I do a dialup, it all works fine... when accessing with the LAN default getaway, the issue happens...
Here is a route print of both in LAN and dialup, in case someone can see something helpfull...

I have tried almost every setting in the router, using different dns servers, disabling the DNS CLient service, dealing with lots of TCP/IP tweaks with no success... this is very annoying...

LAN route print

===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x1000003 ...00 d0 59 59 20 b2 ...... Intel 8255x-based Integrated Fast Ethernet

===========================================================================
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      192.168.0.1    192.168.0.19       1
        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1
      192.168.0.0    255.255.255.0     192.168.0.19    192.168.0.19       1
     192.168.0.19  255.255.255.255        127.0.0.1       127.0.0.1       1
    192.168.0.255  255.255.255.255     192.168.0.19    192.168.0.19       1
        224.0.0.0        224.0.0.0     192.168.0.19    192.168.0.19       1
  255.255.255.255  255.255.255.255     192.168.0.19    192.168.0.19       1
Default Gateway:       192.168.0.1
===========================================================================
Persistent Routes:
  None






Dialup route print

===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x1000003 ...00 d0 59 59 20 b2 ...... Intel 8255x-based Integrated Fast Ethernet

0x2000004 ...00 53 45 00 00 00 ...... WAN (PPP/SLIP) Interface
===========================================================================
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0   62.151.104.228  62.151.104.228       1
          0.0.0.0          0.0.0.0      192.168.0.1    192.168.0.19       2
   62.151.104.228  255.255.255.255        127.0.0.1       127.0.0.1       1
   62.255.255.255  255.255.255.255   62.151.104.228  62.151.104.228       1
        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1
      192.168.0.0    255.255.255.0     192.168.0.19    192.168.0.19       1
     192.168.0.19  255.255.255.255        127.0.0.1       127.0.0.1       1
    192.168.0.255  255.255.255.255     192.168.0.19    192.168.0.19       1
        224.0.0.0        224.0.0.0   62.151.104.228  62.151.104.228       1
        224.0.0.0        224.0.0.0     192.168.0.19    192.168.0.19       1
  255.255.255.255  255.255.255.255     192.168.0.19    192.168.0.19       1
Default Gateway:    62.151.104.228
===========================================================================
Persistent Routes:
  None

Thanks all!!!
0
 

Author Comment

by:demienx
ID: 12022915
Because the complexity of the issue, I have raised the points...
thx again!
0
 

Author Comment

by:demienx
ID: 12376278


Sadly I now know what the problem is...

My ISP has installed a transparent proxy that hijacks all connections on port 80. That's why no matter what I had in my hosts file, it was ignored cos the proxy was returning the content based in the url I was requesting doing his own DNS resollution...

This is really annoying thing and not what I want as an internet connection...

So correct answer is the 1st one from LucF.

Thanks for all your comments guys.
0
 
LVL 32

Expert Comment

by:Luc Franken
ID: 12381521
Great to hear you finally got it sorted!

Take care,

LucF
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 12382074
glad you are resolved but even if your ISP is a root DNS server, it cannot stop resolver cache or host file resolution?

Pete
0
 

Author Comment

by:demienx
ID: 12386103
Not sure what you mean PeteLong...

Right it can not stop my address resollution... however when my browser request one url address, they seem to do not take care of what host I'm trying to connect to, just what domain and request path.
0

Featured Post

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

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 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