Skip to main content

/etc/hosts

A descendant of the HOSTS.TXT file is the hosts file. On Linux, this file resides at /etc/hosts. It has a very simple syntax:

# <IP ADDRESS> <HOSTNAME> [HOSTNAME or alias] ...

An example of an /etc/hosts file is the following:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost
localhost.localdomain localhost6 localhost6.localdomain6

10.100.42.4 laser4 laser4.example.com

10.100.42.1 mail mail.example.com

This hosts file usually takes precedence over other resolution methods:

  • Per-server IP address to host database
  • Administrator-managed.