How to manage DNS: Part II

In the previous Windows XP Professional Here’s How column, we looked at how to configure your operating system to make use of DNS (Domain Name System) efficiently, and how the built-in DNS lookup cache service works.

Windows XP Professional can also make use of a simple text file, called HOSTS, for name resolution. This file is located in %windir%\system32\drivers\etc (“etc” being the traditional UNIX name for the directory in which system configuration files are stored).

Don’t confuse the HOSTS file with the LMHOSTS one; the former is used for name resolution lookups, the latter for LanManager, i.e., Windows networking, resolution. The HOSTS file lets you map IP addresses to host names, in this format:

IP address FQDN host-aliases

So, if you have a domain called example.com.au and a host called mycomputer with the IP address 192.168.1.1, you might enter (as Administrator, using Notepad or WordPad)

192.168.1.1 mycomputer.example.com.au mycomputer mycomp

into the HOSTS file. This means that “mycomp”, “mycomputer” and “mycomputer.example.com.au” all resolve to the same IP address.

Windows XP reads this file before attempting to resolve a name via DNS, so be careful with what you put in here. Make sure the IP addresses and host names are correct, and don’t “steal” any that might be in use by someone else.

If you have to manage name resolution for a large number of systems, it is, of course, preferable to maintain a centralised DNS configuration instead of having to update HOSTS files on each single system. This is why by default the HOSTS file on Windows XP only comes with a single entry (for localhost, which points to the 127.0.0.1 loopback interface IP address of the TCP/IP stack).

However, there are situations — such as when you don’t have easy access to DNS resolution due to poor/intermittent network connectivity, or troubleshooting — where the HOSTS file could be useful.

On small networks, adding the IP addresses and host names/aliases of commonly accessed systems speeds up lookups for these, without having to set up DNS for them. This also prevents unnecessary DNS queries from going out on the Internet, which is always a good thing.

The HOSTS file can even be used as crude access control device: let’s say you want to block an obnoxious pop-up ad site called really.annoyingads.com. Enter this into your HOSTS file:

127.0.0.1 really.annoyingads.com

When your browser requests the IP address for really.annoyingads.com, it receives the address for the loopback interface instead of the real one. The content from really.annoyingads.com doesn’t get served up in your browser; in fact, this method blocks all traffic to and from really.annoyingads.com. The drawback to this method is that it’s cumbersome to manage a HOSTS file with many entries, and it’s a blunderbuss approach: you can’t be selective about the traffic you wish to be rid of and everything gets blocked, so some sites won’t work. Also, you can’t use wild-cards, such as *.annoyingads.com — each single host name has to be listed.

Working with static IP addresses

Another use for the HOSTS files is when you use Internet Connection Sharing (ICS), but would like to configure it for hosts with static IP addresses instead of dynamic ones — with ICS active, IP addresses are allocated with the Dynamic Host Configuration Protocol service in Windows XP by default, in the IANA (Internet Assigned Numbers Authority) 192.168.0.0 range, which is one of the sub-networks reserved for non-Internet routable local area network addressing.

If you have a server or other device on your network to which you point other hosts, having its IP address change due to DHCP allocation is inconvenient, so here’s how to make ICS work with hosts that have static IP addresses.

First, you must use static IP addresses in the 192.168.0.0 network range, because this is hard-coded into Windows XP and cannot easily be changed.

Second, when picking a static IP address, only use one between 192.168.0.2 to 192.168.0.254; 192.168.0.0 is the network address in this case, and ICS must use 192.168.0.1 as the default gateway and the DNS server. 192.168.0.255 is the network broadcast address, so don’t use that, either.

Another ICS is quirk is that you have to use the mshome.net domain name. Enter this as the DNS Suffix on the system with the static IP address (Control Panel-Network Connections-Local Area Connection-General-Properties-Internet Protocol (TCP/IP)-Properties-Advanced-DNS-DNS suffix for this connection).

On the system running ICS, edit the HOSTS file to add the systems with the static IP address. Let’s say you have “mycomputer” with an IP address of 198.168.0.5 that you wish to use ICS. Add this to HOSTS:

5.5.5.5 mycomputer.mshome.net

Check the IP address, host name spelling, save the file, and HOSTS is ready to use ICS to access the Internet.

Join the newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Juha Saarinen

PC World
Show Comments

Cool Tech

SanDisk MicroSDXC™ for Nintendo® Switch™

Learn more >

Breitling Superocean Heritage Chronographe 44

Learn more >

Toys for Boys

Family Friendly

Panasonic 4K UHD Blu-Ray Player and Full HD Recorder with Netflix - UBT1GL-K

Learn more >

Stocking Stuffer

Razer DeathAdder Expert Ergonomic Gaming Mouse

Learn more >

Christmas Gift Guide

Click for more ›

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?