Hosts (File): History
Please note this is an old version of this entry, which may differ significantly from the current revision.
Subjects: Others
Contributor:

The computer file hosts is an operating system file that maps hostnames to IP addresses. It is a plain text file. Originally a file named HOSTS.TXT was manually maintained and made available via file sharing by Stanford Research Institute for the ARPANET membership, containing the hostnames and address of hosts as contributed for inclusion by member organizations. The Domain Name System, first described in 1983 and implemented in 1984, automated the publication process and provided instantaneous and dynamic hostname resolution in the rapidly growing network. In modern operating systems, the hosts file remains an alternative name resolution mechanism, configurable often as part of facilities such as the Name Service Switch as either the primary method or as a fallback method.

  • hosts.txt
  • name resolution
  • file sharing

1. Purpose

The hosts file is one of several system facilities that assists in addressing network nodes in a computer network. It is a common part of an operating system's Internet Protocol (IP) implementation, and serves the function of translating human-friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network.

In some operating systems, the contents of the hosts file is used preferentially to other name resolution methods, such as the Domain Name System (DNS), but many systems implement name service switches, e.g., nsswitch.conf for Linux and Unix, to provide customization. Unlike remote DNS resolvers, the hosts file is under the direct control of the local computer's administrator.[1]

2. File Content

The hosts file contains lines of text consisting of an IP address in the first text field followed by one or more host names. Each field is separated by white space – tabs are often preferred for historical reasons, but spaces are also used. Comment lines may be included; they are indicated by an octothorpe (#) in the first position of such lines. Entirely blank lines in the file are ignored. For example, a typical hosts file may contain the following:

127.0.0.1 localhost loopback ::1 localhost 

This example only contains entries for the loopback addresses of the system and their host names, a typical default content of the hosts file. The example illustrates that an IP address may have multiple host names (localhost and loopback), and that a host name may be mapped to both IPv4 and IPv6 IP addresses, as shown on the first and second lines respectively.

3. Location in the File System

The location of the hosts file in the file system hierarchy varies by operating system. It is usually named hosts, without an extension.

Operating System Version(s) Location
Unix, Unix-like, POSIX   /etc/hosts[2]
Microsoft Windows 3.1 %WinDir%\HOSTS
95, 98, ME %WinDir%\hosts[3]
NT, 2000, XP,[4] 2003, Vista,
2008, 7, 2012, 8, 10
%SystemRoot%\System32\drivers\etc\hosts[5]
Windows Mobile, Windows Phone   Registry key under HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts
Apple Macintosh 9 and earlier Preferences or System folder
Mac OS X 10.0–10.1.5[6] (Added through NetInfo or niload)
Mac OS X 10.2 and newer /etc/hosts (a symbolic link to /private/etc/hosts)[6]
Novell NetWare   SYS: \hosts
OS/2, eComStation, ArcaOS   "bootdrive":\mptn\etc\
Symbian Symbian OS 6.1–9.0 C:\system\data\hosts
Symbian OS 9.1+ C:\private\10000882\hosts
MorphOS NetStack ENVARC:sys/net/hosts
AmigaOS < 4 AmiTCP:db/hosts
4 DEVS:Internet/hosts
AROS   ENVARC:AROSTCP/db/hosts
Android   /etc/hosts (a symbolic link to /system/etc/hosts)
iOS iOS 2.0 and newer /etc/hosts (a symbolic link to /private/etc/hosts)
TOPS-20   <SYSTEM>HOSTS.TXT
Plan 9   /lib/ndb/hosts
BeOS   /boot/beos/etc/hosts[7]
Haiku   /system/settings/network/hosts[8]
OpenVMS UCX UCX$HOST
TCPware TCPIP$HOST
RISC OS 3.7, 5 !Boot.Resources.!Internet.files.Hosts
later boot sequence !Boot.Choices.Hardware.Disabled.Internet.Files.Hosts[9]

4. History

The ARPANET, the predecessor of the Internet, had no distributed host name database. Each network node maintained its own map of the network nodes as needed and assigned them names that were memorable to the users of the system. There was no method for ensuring that all references to a given node in a network were using the same name, nor was there a way to read the hosts file of another computer to automatically obtain a copy.

The small size of the ARPANET kept the administrative overhead small to maintain an accurate hosts file. Network nodes typically had one address and could have many names. As local area TCP/IP computer networks gained popularity, however, the maintenance of hosts files became a larger burden on system administrators as networks and network nodes were being added to the system with increasing frequency.

Standardization efforts, such as the format specification of the file HOSTS.TXT in RFC 952, and distribution protocols, e.g., the hostname server described in RFC 953, helped with these problems, but the centralized and monolithic nature of hosts files eventually necessitated the creation of the distributed Domain Name System (DNS).

On some old systems a file named networks is present that has similar to hosts file functions containing names of networks.

5. Extended Applications

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.[10]
Internet resource blocking
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.[11] 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.[12][13]
Fravia described these files variously as "scrolls", "precious", and "powerful" in his anti-advertisement pages, where this usage of hosts was first published.[13]
Software piracy
Some pirated versions of software rely on a modified hosts file to prevent software from contacting the activation servers of the publisher, although activation servers sometimes appear in general purpose hosts files.[12]

6. Security Issues

The hosts file may present an attack vector for malicious software. The file may be modified, for example, by adware, computer viruses, or trojan horse software to redirect traffic from the intended destination to sites hosting malicious or unwanted content.[14] The widespread computer worm Mydoom.B blocked users from visiting sites about computer security and antivirus software and also affected access from the compromised computer to the Microsoft Windows Update website. In some cases malware has modified the library responsible for loading the hosts file in order to redirect it to a file it is able to control freely.[15]

The content is sourced from: https://handwiki.org/wiki/Hosts_(file)

References

  1. "Cisco Networking Academy Program: First-Year Companion Guide", Cisco Systems, Inc., 2002 (2nd Edition), page 676, ISBN:1-58713-025-4
  2. "Linux Network Administrators Guide: Writing hosts and networks files". https://www.tldp.org/LDP/nag2/x-087-2-iface.simple-resolv.html. Retrieved May 16, 2010. 
  3. "Hosts File". http://support.isoc.net/Page.aspx/117/hosts.html. Retrieved August 10, 2011. 
  4. "Microsoft KB Q314053: TCP/IP and NBT configuration parameters for Windows XP". https://support.microsoft.com/en-us/kb/314053. Retrieved August 28, 2010. 
  5. "Microsoft KB 972034 Revision 2.0: default hosts files". http://support.microsoft.com/kb/972034. Retrieved August 28, 2010. 
  6. "Mac OS X: How to Add Hosts to Local Hosts File". http://support.apple.com/kb/TA27291?viewlocale=en_US. Retrieved August 28, 2010. 
  7. "The Haiku/BeOS Tip Server". http://betips.net/1997/09/09/aliases-via-the-hosts-file/. Retrieved November 30, 2012. 
  8. "Haiku UserGuide:Network". https://www.haiku-os.org/docs/userguide/en/preferences/network.html/. Retrieved January 17, 2019. 
  9. RISC OS 6.14
  10. "Building / Testing via the Hosts File". OCIO. https://web.osu.edu/technical-support/tips-tricks/hosts-file/. Retrieved 5 August 2018. 
  11. "Gordon and -Tx explanations about the use of Gordon's hosts file". +Fravia. http://search.lores.eu/gorhost.htm. Retrieved 5 August 2018. 
  12. Hofstetter, Constantin. "/etc/hosts to block shock sites etc.". https://gist.github.com/consti/8022703. Retrieved 5 August 2018. 
  13. Vianello, Francesco "Fravia". "Antiadvertisement Lab". +Fravia. http://search.lores.eu/antiadve.htm. Retrieved 5 August 2018. 
  14. "Remove Trojan.Qhosts – Symantec". http://www.symantec.com/security_response/writeup.jsp?docid=2003-100116-5901-99&tabid=1. Retrieved May 16, 2010. 
  15. Arntz, Pieter. "Hosts file hijacks". https://blog.malwarebytes.com/cybercrime/2016/09/hosts-file-hijacks/. Retrieved 5 August 2018. 
More
This entry is offline, you can click here to edit this entry!
ScholarVision Creations