It is a plain text file located within your system directory. It has no file extension.
- Windows 2000 - c:\winnt\system32\drivers\etc\hosts
- Windows XP, 2003 - c:\windows\system32\drivers\etc\hosts
- You'll find equivalent files in other OS's (e.g. Unix)
Your Hosts file overrides DNS, forcing HTTP requests to route the way you specify.
Why is it Useful?
There are all kinds of uses for Hosts, depending on your problem at hand. Here are some examples:
- You set up numerous IIS sites (e.g. http://mysite.com) in a development environment (server OS), and want to test them via a browswer.
- You are developing a single site with multiple behaviors based on domain name (e.g. http://myBlueSite.com has a blue background; http://myRedSite.com has a red background). You want to be able to test these behaviors.
- Your are troubleshooting your company's load-balanced server farm. Customers are complaining about a site/application, but you are having difficulty recreating. If the problem is isolated to a specific server, you can force http requests to each server in the farm, provided you have the list of IP addresses.
- You want to block various ad/banner nuisances.
You are developing a fictional site to IIS, running Windows XP. Call this site http://diablolovessteak.com.
- Open c:\windows\system32\drivers\etc\hosts in a text editor
- Add the following line:
- 127.0.0.1 diablolovessteak.com
- Save the file.
- Close any open internet browsers.
- Open a browser and go to http://diablolovessteak.com
The request will open the home page of your default web site. If you've never used Hosts, give it a shot!