Tips from the Windows Pros: The Hosts File


If you have an office LAN, especially one with mixed and matched computers, you're probably like me and have a chart of computer names and IP addresses posted on your wallnot just computers, but routers, firewalls, monitored devices, and all manner of devices. Who knows? Soon the espresso machine might be wired in, too.

On a corporate or enterprise LAN, the LAN administrators will probably enter each device into the organization's Domain Name Service system, under your own default domain, so that you can type a command like ping firewall instead of having to type ping firewall.mycompany.com or, worse, something like ping 192.168.56.102.

On a workgroup LAN, you probably don't have your own domain name server. Or your network manager hasn't entered names for the networked devices you use most frequently (for example, your new Linksys "Wireless-G Router and Espresso Maker"). On a heterogeneous network, your Macintosh and testbed Linux machines probably aren't in any domain name list anywhere.

The hosts file is the answer to this annoying situation. You can add entries to the file\windows\system32\drivers\etc\hosts to associate names with IP addresses. The Windows domain-name lookup system looks first in the hosts file before consulting the network, so you can add entries for your own workgroup's computers and devices, regardless of operating system.

The format is simple. Edit the file in Notepad. Add lines to the file, listing IP addresses at the left margin, followed by some whitespace (tabs or spaces), followed by one or more names. You can enter simple names or full domain names. Simple names are assumed to belong to your own domain.

My hosts file looks like this:

 127.0.0.0 localhost lh 192.168.56.102 firewall fw 192.168.56.45 macone 

The first entry is the default entry shipped with Windows. localhost stands for "my own computer" and is used for internal testing of the network software. I've added a second name, lh, because I'm lazy and would rather type ping lh than ping localhost.

I added the second entry myself to give a name to my network's firewall. I can now configure the firewall by typing telnet firewall or, better yet, telnet fw rather than having to look up at that sheet on the wall and type a bunch of numbers.

Finally, there's an entry for my Macintosh computer, macone. This way, I can view its Web server's home page from Internet Explorer using http://macone rather than having to remember its IP address.

This file also serves as a sort of documentation of my network, as it records important IP addresses. One thing you must watch out for, though, is that Windows checks this file before using the real DNS system to look up names. If you put a name in your LAN's (or the Internet's) DNS system, and the computer's IP address later changes, your hosts file will be incorrect. It's best to use this file only for machines that are in nobody's DNS system.



Special Edition Using Microsoft Windows XP Professional
Special Edition Using Microsoft Windows XP Professional (3rd Edition)
ISBN: 0789732807
EAN: 2147483647
Year: 2003
Pages: 450

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net