ArticleslgStudy

science

Hosts (file)

Hosts (file) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Hosts (file) rather than just read about it. In short: The computer file hosts is an operating system file that maps hostnames to IP addresses. It is a plain text file.

Key takeaways

  • Hosts (file) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Hosts (file) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Hosts (file) from memory before moving on to harder problems.

Reference excerpt

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 the Stanford Research Institute for the ARPANET membership, containing the hostnames and addresses 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, often configurable as part of facilities such as the Name Service Switch as either the primary method or a fallback method.

Purpose The hosts file is one of several system facilities that assist 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 are 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.

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. The host names map to the IPs, not vice versa. 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.

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.

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 used 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 of maintaining an accurate hosts file small. 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. The earliest effort to standardize host naming was proposed in 1971 by Peggy Karp of MITRE, who published RFC 226, defining a standard set of host mnemonics mapping network addresses to human-readable names. Karp's list has been described as the first hosts.txt file, the predecessor of the modern root file. Later 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 address these problems, but the centralized and monolithic nature of hosts files eventually led to the creation of the distributed Domain Name System (DNS). On some old systems a file named networks is present that is similar to a hosts file, containing names of networks.

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. 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. 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. Fravia described these files variously as "scrolls", "precious", and "powerful" in his anti-advertisement pages, where this usage of hosts was first published. 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.

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. 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.

See also DNSBL, a DNS-based blackhole list Content-control software Ad filtering

References

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Hosts (file)

Start with the simplest possible case. Write down what Hosts (file) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Hosts (file) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Hosts (file) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Hosts (file)

In research
Hosts (file) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Hosts (file) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Hosts (file) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Configuration files, Domain Name System, so understanding it makes those chapters shorter.
In everyday life
Look for Hosts (file) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Hosts (file)” →

How to study Hosts (file) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Hosts (file) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Hosts (file) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Hosts (file) in simple terms?

The computer file hosts is an operating system file that maps hostnames to IP addresses. It is a plain text file.

Why does Hosts (file) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Hosts (file)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Hosts (file).

Tags

  • Configuration files
  • Domain Name System

Keep exploring