hosts (file)

from Wikipedia, the free encyclopedia

The file " hosts " (plural of host , English " hosts" or "host" in the sense of provider, provider ; usually in lower case unless the file system does not support this) is a local configuration file to Map host names to IP addresses . This system - file was originally the site of the Domain Name System used. Today it is generally only used for permanent assignment in local (and virtual) computer networks ( LAN ).


The format of the hosts file is originally from the Berkeley Software Distribution , with the UNIX version 4.3, which in conjunction with the developed there network - Stack stands. It was later adopted for various other operating systems .

The file name lmhosts , which is the abbreviation for “Lan-Manager Hosts” and was used in Windows systems by the LAN manager and later also by the SMB software Samba , also comes from that time .

Before the introduction of the Domain Name System (DNS), computer names on the Internet were resolved using these host files. The distribution and updating of these files was a logistical problem. For this reason, hosts files are rarely or no longer used on the Internet and in larger networks. Also loopback addresses do not need an entry in the Hosts file nowadays.

Technical details

If a host name has to be translated (or "resolved") into an IP address (or vice versa), the operating systems first attempt to resolve the name locally using the assignments saved in the hosts file, before other methods ( DNS , WINS etc.) .) should be tried. On Unix-like systems , the order is determined by entries in the /etc/nsswitch.conf file .

In Windows versions that are no longer based on DOS ( Windows NT or higher), the file is usually no longer required, as the Windows Internet Naming Service usually takes over the task of the current operating system versions .

Paths under different operating systems

  • Windows
    • NT line from Windows 8
      • %windir%\system32\drivers\etc
    • NT line up to and including Windows 7
      • %SystemRoot%\system32\drivers\etc\hostsis system default; the path is saved in the registration database and can be adjusted:\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath
    • 95 / 98 / Me
      • %WinDir%\hosts
    • mobile
      • one key per host in the registry under \HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts
  • Unix , FreeBSD , OpenBSD , GNU / Linux
    • /etc/hosts
  • Android
    • /etc/hostsor /system/etc/hosts( /etcis a link with /system/etc)
  • Darwin
    • macOS
      • /etc/hostsor /private/etc/hosts( /etcis a link with /private/etc)
    • iOS
      • /private/etc/hosts
  • Plan 9
    • /lib/ndb/hosts
  • Haiku
    • /boot/common/settings/network/hosts
  • AmigaOS
    • AmiTCP:db/hosts
    • DEVS:Internet/hosts (from version 4)
  • AROS
    • ENVARC:AROSTCP/db/hosts
  • MorphOS
    • ENVARC:sys/net/hosts
  • OS / 2 and eComStation
    • "bootdrive":\mptn\etc\hosts
  • Series 60
    • 1st and 2nd edition:
      • C:\system\data\hosts
    • 3rd edition
      • C:\private\10000882\hosts (Access not easily possible due to platform security.)
  • OpenVMS

File format

The file consists of a tabular list of IP addresses and associated host names . The columns are separated by spaces or tabs . A typical hosts file looks like this:

# Kommentare werden durch eine vorangestellte Raute eingeleitet localhost.localdomain localhost
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

The first line is used to assign the local host in the IPv4 protocol, the following lines assign IPv6 addresses to.

It should be noted that each subdomain must also be listed, because if the entry does not exist, it will be resolved again.


Host files make it possible to permanently assign a DNS entry to an IP address, which enables, for example, the clear assignment and use in a network with the same name assigned several times. Likewise, computers that have other, possibly unfavorable or missing names, can be given a simple and precisely identifiable name. The use of the hosts file can therefore compensate for a temporary failure of the DNS server. It is also possible to block addresses by redirecting them to the loopback interface (host name localhost, IP address The request for a specific domain name, e.g. B., answered in such a way that it refers to the address of your own PC. Since the page you are looking for is not available there, you get a page loading error.

Web developers also often register domains for which they are designing content. The contents of the local web server can thus be tested as if they were on a web server with the same domain in the Internet. However, the domain can only be reached locally. Processing of scripts and tasks is possible immediately with the later names.

Use as a filter

Sometimes the hosts file is used to block known advertising servers by entering it as an alias for (better The peculiarity of this method compared to the advertising filters to be installed is that this blocking is valid throughout the system, i.e. it is not limited to just one browser. In addition, such filters can also be used against some malware if they try to retrieve instructions from known servers.

However, excessive use of this file can slow down the entire name resolution process as this file is not optimized for large amounts of data. Ready-made files for use as advertising filters or DNS replacements are available on the Internet.


Windows operating systems in particular are often the target of viruses that modify the hosts file in such a way that users are directed to fake online services. With this trick, a user can be redirected to a fake online banking site (see Pharming and Phishing ). If in doubt, it is advisable to pay attention to encrypted connections and to check the certificate of the connection key .

This is usually accompanied by entries that prevent the antivirus programs from being updated . You can reach the manufacturer's servers through their Internet addresses; the updated virus signatures are provided on these servers . If, because of the invalid or incorrectly entered IP addresses in the hosts file, these cannot be reached, these entries prevent the software from being updated automatically or manually. However , it should be possible to prevent such manipulations beforehand by keeping up-to-date and correctly configured security software ( user account , active background monitor, active firewall).

Another (here deliberately desired) method of manipulation was specially developed by the creators of black copies of software. Since many types of software have to be activated online, an entry is made in the hosts file with the name of the server of the legal software provider that is contacted for activation. This is now only provided with the IP address of a server maintained by the providers of the black copies. The illegally obtained activation keys are then on this. The manipulation of the file is done with a supplied program.

Web links

Individual evidence

  1. ↑ Blocking access to certain websites - July 3, 2012