Helping people with computers... one answer at a time.
In case you need to test your website, there are ways that you can fake the DNS IP lookup to be able to do so. We'll take a look at how that's done.
Can I fake the DNS ip lookup to test my website?
The situation is this: you have a working web site, and you're about to move it or make dramatic changes to it. So you make a copy of the web site at a different ip address, possibly with a different temporary domain name. You make all your changes and then want to test it out using the correct URL - the "real" domain name. How can you do that without actually changing the internet's DNS entry for your domain?
It's not hard at all.
Let's look at the example in more detail. Say you're the proud owner of http://example.com, and it lives on a server at IP address 188.8.131.52. You're about to make major changes to it, so you create a new domain, http://test.example.com on a different server with a different IP address - 184.108.40.206.
After you make your changes, you want (or in come cases you may need) to test the new server at the new address but use the "correct", real name of the site: example.com and not test.example.com.
In other words, you would like to change example.com to point to 220.127.116.11 instead of 18.104.22.168. Ideally, though, you would not want that to be true for everyone. In fact, you want that to be true only for you. While you're testing your new site, you want the world to continue to only see example.com at the old IP address 22.214.171.124.
Enter the "hosts" file in Windows. This text file contains IP-to-name mappings that override DNS. In fact, if Windows finds an entry in the DNS file, then the internet DNS is never even consulted.
The hosts file lives in c:\windows\system32\drivers\etc\hosts (where "c:\windows" is your Windows directory). It's just a text file, and each line that doesn't begin with a "#" character is of the form:
number space name
So for our example, we would edit this hosts file and add the following line:
Now, on our machine only "example.com" will reference the new IP address, 126.96.36.199, instead of whatever DNS has listed.
There are a couple of caveats:
If this approach sounds vaguely familiar, it's also a technique used by viruses and spyware. By placing entries into your hosts file, malware writers can redirect you to their sites or prevent you from accessing other sites. And that brings us to a final caveat:
Comments on this entry are closed.
If you have a question, start by using the search box up at the top of the page - there's a very good chance that your question has already been answered on Ask Leo!.
If you don't find your answer, head out to http://askleo.com/ask to ask your question.