Debian Codegraph @

upstream/debian-unstable/man5/hosts.5

raw
1 .\" Copyright 2000, Manoj Srivastava <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
5 .\"
6 .TH hosts 5 2026-02-11 "Linux man-pages 6.18"
7 .SH NAME
8 hosts \- static table lookup for hostnames
9 .SH SYNOPSIS
10 .nf
11 .B /etc/hosts
12 .fi
13 .SH DESCRIPTION
14 This manual page describes the format of the
15 .I /etc/hosts
16 file.
17 This file is a simple text file that associates IP addresses
18 with hostnames, one line per IP address.
19 For each host a single
20 line should be present with the following information:
21 .RS
22 .P
23 IP_address canonical_hostname [aliases...]
24 .RE
25 .P
26 The IP address can conform to either IPv4 or IPv6.
27 Fields of the entry are separated by any number of blanks and/or
28 tab characters.
29 Text from a "#" character until the end of the line is
30 a comment, and is ignored.
31 Host names may contain only alphanumeric
32 characters, minus signs ("\-"), and periods (".").
33 They must begin with an
34 alphabetic character and end with an alphanumeric character.
35 Optional aliases provide for name changes, alternate spellings,
36 shorter hostnames, or generic hostnames (for example,
37 .IR localhost ).
38 If required, a host may have two separate entries in this file;
39 one for each version of the Internet Protocol (IPv4 and IPv6).
40 .P
41 The Berkeley Internet Name Domain (BIND) Server implements the
42 Internet name server for UNIX systems.
43 It augments or replaces the
44 .I /etc/hosts
45 file or hostname lookup, and frees a host from relying on
46 .I /etc/hosts
47 being up to date and complete.
48 .P
49 In modern systems, even though the host table has been superseded by
50 DNS, it is still widely used for:
51 .TP
52 .B bootstrapping
53 Most systems have a small host table containing the name and address
54 information for important hosts on the local network.
55 This is useful
56 when DNS is not running, for example during system bootup.
57 .TP
58 .B NIS
59 Sites that use NIS use the host table as input to the NIS host
60 database.
61 Even though NIS can be used with DNS, most NIS sites still
62 use the host table with an entry for all local hosts as a backup.
63 .TP
64 .B isolated nodes
65 Very small sites that are isolated from the network use the host table
66 instead of DNS.
67 If the local information rarely changes, and the
68 network is not connected to the Internet, DNS offers little
69 advantage.
70 .SH FILES
71 .I /etc/hosts
72 .SH NOTES
73 Modifications to this file normally take effect immediately,
74 except in cases where the file is cached by applications.
75 .SS Historical notes
76 RFC\ 952 gave the original format for the host table, though it has
77 since changed.
78 .P
79 Before the advent of DNS, the host table was the only way of resolving
80 hostnames on the fledgling Internet.
81 Indeed, this file could be
82 created from the official host data base maintained at the Network
83 Information Control Center (NIC), though local changes were often
84 required to bring it up to date regarding unofficial aliases and/or
85 unknown hosts.
86 The NIC no longer maintains the hosts.txt files,
87 though looking around at the time of writing (circa 2000), there are
88 historical hosts.txt files on the WWW.
89 I just found three, from 92,
90 94, and 95.
91 .SH EXAMPLES
92 .EX
93 # The following lines are desirable for IPv4 capable hosts
94 127.0.0.1 localhost
95 \&
96 # 127.0.1.1 is often used for the FQDN of the machine
97 127.0.1.1 thishost.example.org thishost
98 192.168.1.10 foo.example.org foo
99 192.168.1.13 bar.example.org bar
100 146.82.138.7 master.debian.org master
101 209.237.226.90 www.opensource.org
102 \&
103 # The following lines are desirable for IPv6 capable hosts
104 ::1 localhost ip6\-localhost ip6\-loopback
105 ff02::1 ip6\-allnodes
106 ff02::2 ip6\-allrouters
107 .EE
108 .SH SEE ALSO
109 .BR hostname (1),
110 .BR resolver (3),
111 .BR host.conf (5),
112 .BR resolv.conf (5),
113 .BR resolver (5),
114 .BR hostname (7),
115 .BR named (8)
116 .P
117 Internet RFC\ 952
118 .\" .SH AUTHOR
119 .\" This manual page was written by Manoj Srivastava <[email protected]>,
120 .\" for the Debian GNU+Linux system.