Welcome Login

Windows: Hosts configuration file


Windows

The hosts file is a computer file used in an operating system to map hostnames to IP addresses.

 

The hosts file is a plain-text file and is traditionally named hosts.

No wildcards are allowed and only the main domain name is a valid entry.

1. Host file is loaded into memory (cache) at startup,

2. then windows checks it before it queries any dns servers, which enables it to override addresses in the dns.

 

Eg: to host file at:

c:\WINDOWS\system32\drivers\etc\hosts

 

Add following entry to direct url dev.andrewsin.com to a server

83.111.111.111      dev.andrewsin.com

 

 

Eg2: loopback:

This entry is a not an actual Internet IP address but defines a local address and can be used to direct the computer to send a packet to itself.

127.0.0.1       localhost

 


Blocking sites:

By overriding addresses, you can prevent access to sites by redirecting any connections back to the your machine (local machine).

Eg: By adding following entry to hosts file:

It blocks all files supplied by that DoubleClick Server to the web page you are viewing.

127.0.0.1     ad.doubleclick.net

 

 

 

For more details on blocking sites, see here.


Created on: Wednesday, August 17, 2011 by Andrew Sin