1hosts(4)                         File Formats                         hosts(4)
2
3
4

NAME

6       hosts - host name database
7

SYNOPSIS

9       /etc/inet/hosts
10
11
12       /etc/hosts
13
14
15       /etc/inet/ipnodes
16
17

DESCRIPTION

19       The  hosts  file is a local database that associates the names of hosts
20       with their Internet Protocol (IP) addresses. An IP address  can  be  in
21       either  IPv4  or IPv6 format. The hosts file can be used in conjunction
22       with, or instead of, other hosts databases, including the  Domain  Name
23       System  (DNS),  the NIS hosts map, the NIS+ hosts table, or information
24       from an LDAP server. Programs use library interfaces to access informa‐
25       tion in the hosts file.
26
27
28       Note  that  /etc/hosts  and  /etc/inet/ipnodes  are  symbolic  links to
29       /etc/inet/hosts.
30
31
32       The hosts file has one entry for each IP address of  each  host.  If  a
33       host  has more than one IP address, it will have one entry for each, on
34       consecutive lines. The format of each line is:
35
36
37       IP-address official-host-name nicknames...
38
39
40       Items are separated by any number of SPACE and/or TAB  characters.  The
41       first  item on a line is the host's IP address. The second entry is the
42       host's official name. Subsequent entries on the same line are  alterna‐
43       tive  names  for  the  same  machine,  or  "nicknames."  Nicknames  are
44       optional.
45
46
47       For a host with more than one IP address, consecutive entries for these
48       addresses  may contain the same or differing nicknames. Different nick‐
49       names are useful for assigning distinct names to different addresses.
50
51
52       A call to gethostbyname(3NSL) returns a  hostent  structure  containing
53       the union of all IPv4 addresses and nicknames from each line containing
54       a  matching  official  name  or  nickname.  A  call   to   getipnodeby‐
55       name(3SOCKET)  is  similar,  but is capable of returning hostent struc‐
56       tures containing IPv4 and IPv6 addresses. Applications might prefer  to
57       use  the  address-family independent getaddrinfo(3SOCKET) API for name-
58       to-address lookups.
59
60
61       A `#' indicates the beginning of a comment; characters up to the end of
62       the line are not interpreted by routines that search the file.
63
64
65       Network addresses are written in one of two ways:
66
67           o      The  conventional  "decimal  dot"  notation  and interpreted
68                  using the inet_addr routine from the Internet address manip‐
69                  ulation library, inet(3SOCKET).
70
71           o      The  IP  Version  6 protocol [IPV6], defined in RFC 1884 and
72                  interpreted using the inet_pton() routine from the  Internet
73                  address manipulation library. See inet(3SOCKET).
74
75
76       This  interface  supports  node  names  as defined in Internet RFC 952,
77       which states:
78
79
80       A "name" (Net, Host, Gateway, or Domain name) is a text string up to 24
81       characters drawn from the alphabet (A-Z), digits (0-9), minus sign (−),
82       and period (.). Note that periods are only allowed when they  serve  to
83       delimit  components of "domain style names". (See RFC 921, "Domain Name
84       System Implementation Schedule," for background).  No  blank  or  space
85       characters  are  permitted  as  part  of a name. No distinction is made
86       between uppercase and lowercase. The first character must be  an  alpha
87       character  [or  a  digit. (RFC 1123 relaxed RFC 952's limitation of the
88       first character to only alpha characters.)] The last character must not
89       be a minus sign or period.
90
91
92       Host  names  must not consist of numbers only. A host name must contain
93       at least one alphabetical or special character.
94
95
96       Although the interface accepts host names longer than 24 characters for
97       the  host  portion  (exclusive of the domain component), choosing names
98       for hosts that adhere to the 24 character restriction will insure maxi‐
99       mum interoperability on the Internet.
100
101
102       A  host  which  serves  as a GATEWAY should have "−GATEWAY" or "−GW" as
103       part of its name. Hosts which do not serve as Internet gateways  should
104       not  use "−GATEWAY" and "−GW" as part of their names. A host which is a
105       TAC should have "−TAC" as the last part of its host name, if  it  is  a
106       DoD host. Single character names or nicknames are not allowed.
107

EXAMPLES

109       Example 1 Example hosts File Entry
110
111
112       The following is a typical line from the hosts file:
113
114
115         192.9.1.20        gaia                        # John Smith
116
117
118
119       Example 2 Example IPv6 Address Entry
120
121
122       The following is an example of an IPv6 hosts entry:
123
124
125         2001:0db8:3c4d:55:a00:20ff:fe8e:f3ad  myhost  # John Smith
126
127
128

SEE ALSO

130       gethostbyname(3NSL),   getipnodebyname(3SOCKET),   inet(3SOCKET),  nss‐
131       witch.conf(4), resolv.conf(4)
132
133
134       Braden, B., editor, RFC 1123, Requirements for Internet Hosts -  Appli‐
135       cation and Support, Network Working Group, October, 1989.
136
137
138       Harrenstien, K., Stahl, M., and Feinler, E., RFC 952, DOD Internet Host
139       Table Specification, Network Working Group, October 1985.
140
141
142       Hinden, R., and Deering, S., editors, RFC 1884, IP Version 6 Addressing
143       Architecture, Network Working Group, December, 1995.
144
145
146       Postel,  Jon,  RFC  921,  Domain  Name  System  Implementation Schedule
147       (Revised), Network Working Group, October 1984.
148

NOTES

150       /etc/inet/hosts is the official SVR4 name of the hosts file.  The  sym‐
151       bolic link /etc/hosts exists for BSD compatibility.
152
153
154       The  symbolic  link /etc/net/ipnodes exists for backwards compatibility
155       with previous Solaris releases.
156
157
158
159SunOS 5.11                        24 Feb 2008                         hosts(4)
Impressum