2

Suppose example.com points to 1.2.3.4 IP address.

I want to be able to put something.example.com in my Windows hosts file so that it goes to another IP address. I've defined it as such in the hosts file.

9.8.7.6 something.example.com

When I ping something.example.com I still get 1.2.3.4 and when I visit the URL, it still resolves the website on 1.2.3.4 instead of from where I want, 9.8.7.6

JdeBP
  • 3,970
  • 17
  • 17
FinalForm
  • 125
  • 4

2 Answers2

6

Perhaps the local resolver cache is queried first? Does running 'ipconfig /flushdns' perhaps resolve the issue?

agy
  • 206
  • 1
  • 1
2

Did you place your hosts file in: C:\Windows\System32\drivers\etc with this syntax:

102.54.94.97 rhino.acme.com

IT_Fixr
  • 235
  • 3
  • 12
  • Also, you must be administrator to save it, so if windows 7: Click Start – search for “Notepad“, right-click and select “Run as Administrator“ then open the hosts file – IT_Fixr Jun 29 '11 at 23:25
  • 1
    The actual issue was, I had to restart my computer. :-/ Strange but true. – FinalForm Jun 29 '11 at 23:42
  • 3
    That's a little odd, host file changes should take immediately. Though a cached DNS lookup may take precedence. Did you try ipconfig /flushdns ? – SpacemanSpiff Jun 30 '11 at 00:33
  • The hosts file should take effect immediately and entries in the hosts file should replace matching entries in the DNS resolver cache upon saving the hosts file. I'm pretty sure that running ipconfig/flushdns will preload the DNS resolver cache with entries from the hosts file along with clearing the DNS resolver cache of entries not contained in the hosts file. – joeqwerty Jun 30 '11 at 03:59