Page 1 of 1

Guide to the HOSTS file This thing is great! Rate Topic: ***** 1 Votes

#1 Moonbat   User is offline

  • D.I.C Regular
  • member icon

Reputation: 36
  • View blog
  • Posts: 424
  • Joined: 30-June 08

Posted 08 July 2008 - 08:40 AM

~Note: For Windows Users Only~
Go to the following directory on your computer

Windows 95/98/ME

Windows NT/2000/2003/XP/Vista

There should be a few files there, click on the one that says hosts. Open this with notepad or some other text editor. These are the contents of the file:
# Copyright (c) 1993-1999 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#		  # source server
#			  # x client host localhost

Now, this file can be useful, annoying, and funny at the same time.


When you enter in a website (like, that domain will have to be matched to an IP address. Windows will have to look in places to find a record matching the domain to an IP. Windows searches in this order.

1. The HOSTS file
2. DNS server <- This is used most of the time when you are browsing the Internet
3. NetBios <- Rarely used

This order can be changed by going into the Registry. (Just to go along with SOP, I advise you not to make changes into the Registry unless you know exactly what you are doing, and that you should back up the Registry just in case).

Windows 95/98/ME

Windows NT, 2000, XP

There are four keys.

HostsPriority (HOSTS file)
DnsPriority (DNS Servers)
NetbtPriority (Netbios)
LocalPriority (Computerís local name)

Each has a value. The lower the number, the higher the priority. You can change the numbers and in effect change the order of how Windows resolves a domain to an IP.

Now that weíve had a little lesson on DNS resolution, letís get back to where we left off. To speed up load times to certain sites, find the IP of the site you visit alot. To do this:

Start >> Run >> type cmd in the box >> DOS prompt will come up >> type the following in bold, replacing with the website you want. ping A number looking like this with various numbers between 0-255 should come up, that's the IP.

Then, go back to the hosts file, and on a new line, type this in the hosts file (replace with your website, and the fake IP with your website's IP)

You can also block ads by finding the website where the ads are coming from and putting the following in your hosts file

Or you may have to put


Many spyware and trojan programs edit the hosts file to redirect you to their site when you go on the Internet. If you are having this kind of problem, check your hosts file to see if any additions have been made that you didn't make.


Do you have access to a friend's computer? Well, just have some fun with them, maybe they have a particular site they like going to. Well, find the IP of the site YOU want them to go to, and make a quick edit of the hosts file.

~NOTE: If a user types in the full url i.e. with the http:// and everything, it wll bypass the hosts file redirection and take them to the right website~

Thanks for reading, and I hope you've learned something!

Is This A Good Question/Topic? 2
  • +

Replies To: Guide to the HOSTS file

#2 pantyhouse   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-July 08

Posted 14 July 2008 - 08:00 AM

Thanks a lot Moonbat!

I appreciate the time you took to teach us something like, this.

Im new around here.

Was This Post Helpful? 0
  • +
  • -

#3 Harlen   User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 40
  • Joined: 08-February 10

Posted 12 February 2010 - 10:43 AM

My family members ridiculously , at times, surf the Internet, so they get viruses when they rely on McAfee and there have been cases when I had to solve their issues when they've been hijacked.

They trust a unreliable company's lies over a experienced deviruser.... This tutorial has helped me a lot and I will attempt to incorporate it with my future security programs that I'll be making once I get good enough with programming.

Thanks so much!

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1