Showing posts with label DNS. Show all posts
Showing posts with label DNS. Show all posts

Wednesday, May 16, 2007

Get To Know Your Hosts File

What is the Hosts File
It is a plain text file located within your system directory. It has no file extension.

  1. Windows 2000 - c:\winnt\system32\drivers\etc\hosts
  2. Windows XP, 2003 - c:\windows\system32\drivers\etc\hosts
  3. You'll find equivalent files in other OS's (e.g. Unix)
What Does it Do?
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:

  1. 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.
  2. 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.
  3. 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.
  4. You want to block various ad/banner nuisances.
Brief Example
You are developing a fictional site to IIS, running Windows XP. Call this site http://diablolovessteak.com.
  1. Open c:\windows\system32\drivers\etc\hosts in a text editor
  2. Add the following line:
  3. 127.0.0.1 diablolovessteak.com
  4. Save the file.
  5. Close any open internet browsers.
  6. 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!

Monday, May 14, 2007

DNS For Dummies

If you are like me, application-heavy and network-light, then DNS is a relative mystery to you. A friend (network guy) gave me the following high level explanation.

You type and enter an address into your browser, e.g. http://diablopup.blogspot.com.



The first thing that happens is your computer asks your ISP's (e.g. AT&T's) DNS server (1) "do you know the IP address for this website?" If it does, it will tell your computer what it is, and you connect directly to the Website Server (3).

If your ISP's DNS server doesn't know, it will ask (in a roundabout way) the website owner’s DNS server for the IP address(2). Then it connects to the website server (3).

Once your ISP's DNS server knows the IP address, it keeps it in cache so it doesn't have to ask again, thereby making the connection quicker on subsequent requests. This is why you sometimes experience a slow page load when visiting a website for the first time, but then witness quicker connection on subsequent visits.

There are more "nuts and bolts" to DNS, but this is an intuitive picture for people who can't work with DNS directly.