Hosts File


Hosts File is a text file that provides a local method for resolution of fully qualified domain names (FQDNs) into their respective IP addresses on a TCP/IP network.

What is Hosts File?

A text file that provides a local method for resolution of fully qualified domain names (FQDNs) into their respective IP addresses on a TCP/IP network. Hosts files are an alternative to DNS servers for name resolution on TCP/IP networks. They are used mainly on small networks or when maintaining a DNS server is impractical.

Hosts File
Hosts File

How does it work?

You can locate the hosts file using the following paths:

  • Microsoft Windows NT, 2000, XP, 2003, Vista, 2008, 7, 2012, 8, 10, 2016: %SystemRoot%\system32\ drivers\etc\Hosts 
  • Microsoft Windows 95 or Windows 98: \%WinDir%\Hosts.sam 
  • Unix, Linux, Posix: /etc/hosts 

Each line in the hosts file contains the IP address of a TCP/IP host followed by the FQDN of the host, followed by an optional comment prefixed with a pound sign (#).

In its function of resolving host names, the hosts file may be used to define any hostname or domain name for use in the local system.

Redirecting local domains

Some web service and intranet developers and administrators define locally defined domains in a LAN for various purposes, such as accessing the company’s internal resources or to test local websites in development.

Blocking unwanted internet resources

Entries in the hosts file may be used to block online advertising, or the domains of known malicious resources and servers that contain spyware, adware, and other malware. This may be achieved by adding entries for those sites to redirect requests to another address that does not exist or to a harmless destination such as the local machine. Commercial software applications may be used to populate the hosts file with entries of known undesirable Internet resources automatically. In addition, user-created hosts files which block nuisance servers are publicly available.

NOTE


Hosts files should contain mappings for hosts on both local and remote networks. Mappings can consist of an IP address and one or more host names (aliases). If you are using hosts files to resolve hostnames on a network, each computer on the network should have a hosts file.

TIP


Place the hostnames that need to be most frequently resolved near the top of the hosts file, because the file is parsed linearly from the beginning.

Editor

Articles posted after being checked by editors.

Recent Content

link to Http Cookie

Http Cookie

In Internet technologies, a cookie is a text file that a Web server saves on a client machine during a Hypertext Transfer Protocol (HTTP) session. HTTP Cookies are used to record information about the client’s usage patterns, including the date and time the client visited the site, which pages were accessed, Web browser preferences, and so on.