DNS is the manageable way to resolve computer names to IP addresses, yet Windows admins usually use host files because they always work. But when you need to make a change to a bunch of host entries, where do you start?


It can be risky to use the Windows host file (which is located at C:\windows\system32\drivers\etc\hosts) for default installations if you need to make a change to a large number of systems with a local entry. Fortunately, there are a few ways to change these entries.

For example, look at a simple host file entry:                    localhost                 dhcp-122                 server94

Imagine that the DHCP-122 host is frequently used and many systems have a host entry with that IP address. As the system becomes more important, it is moved to another network and a static IP address. Assuming there is a resolution mechanism, the task is to replace the entry with a hashed out entry, as shown below:

#              dhcp-122

Let’s also assume that we don’t want to remove the other entries in the file. This change comments out the entry and puts the new IP address in place. In the event that DNS or another mechanism cannot resolve the address, we can easily flip this entry for access.

To accomplish this task for a large number of systems, there are a few ways of going about it. One tool that I came across recently is Advanced Find and Replace, where a text file of paths can be loaded for a large find and replace task. The text file would contain entries like this:


Advanced Find and Replace can then go through all of those paths and make the requested change if the text string exists in the file. This task can also be accomplished with a stream editing tool like Sed for Windows.

Another way to address easy short name resolution without the nightmarish management of host files is to migrate to Windows Server 2008’s DNS engine and use the GlobalNames zone — although the host files would need to be removed for the DNS results to work.

Whatever tool you use to modify the entry, make sure you do not add a file extension to the hosts file — the file will not function correctly with an extension. In general, you should stay away from using host files; however, certain situations warrant their use, and the manageability issues will soon follow.

Stay on top of the latest Windows Server 2003 and Windows Server 2008 tips and tricks with our free Windows Server newsletter, delivered each Wednesday. Automatically sign up today!