hosts entries priority, ignored if not 127.0.0.1


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!
demienxAsked:
Who is Participating?
 
LucFConnect With a Mentor EMEA Server EngineerCommented:
Hi demienx,

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

Greetings,

LucF
0
 
Pete LongTechnical ConsultantCommented:
have you cleared the IE cache

and run a

ipconfig /flushdns

command?
0
 
Pete LongTechnical ConsultantCommented:
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
demienxAuthor Commented:
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
 
Pete LongTechnical ConsultantCommented:
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
 
demienxAuthor Commented:
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
 
demienxAuthor Commented:

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
 
LucFEMEA Server EngineerCommented:
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
 
demienxAuthor Commented:

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
 
demienxAuthor Commented:

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
 
LucFEMEA Server EngineerCommented:
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
 
demienxAuthor Commented:

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
 
Bionicthumb2Commented:
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
 
demienxAuthor Commented:

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
 
demienxAuthor Commented:

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
 
demienxAuthor Commented:
I have also trie to stop the DNS Client service, and still happens the same...

this is driving me mad   }:^ P

0
 
LucFEMEA Server EngineerCommented:
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
 
demienxAuthor Commented:

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
 
demienxAuthor Commented:
Because the complexity of the issue, I have raised the points...
thx again!
0
 
demienxAuthor Commented:


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
 
LucFEMEA Server EngineerCommented:
Great to hear you finally got it sorted!

Take care,

LucF
0
 
Pete LongTechnical ConsultantCommented:
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
 
demienxAuthor Commented:
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
All Courses

From novice to tech pro — start learning today.