'\" te
.\"  Copyright 1989 AT&T Copyright (c) 1988, 1995 Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH HOSTS 4 "Feb 24, 2008"
.SH NAME
hosts \- host name database
.SH SYNOPSIS
.LP
.nf
\fB/etc/inet/hosts\fR
.fi

.LP
.nf
\fB/etc/hosts\fR
.fi

.LP
.nf
\fB/etc/inet/ipnodes\fR
.fi

.SH DESCRIPTION
.sp
.LP
The \fBhosts\fR file is a local database that associates the names of hosts
with their Internet Protocol (IP) addresses. An IP address can be in either
IPv4 or IPv6 format. The \fBhosts\fR file can be used in conjunction with, or
instead of, other hosts databases, including the Domain Name System (DNS), the
NIS \fBhosts\fR map, the NIS+ \fBhosts\fR table, or information from an LDAP
server. Programs use library interfaces to access information in the
\fBhosts\fR file.
.sp
.LP
Note that \fB/etc/hosts\fR and \fB/etc/inet/ipnodes\fR are symbolic links to
\fB/etc/inet/hosts\fR.
.sp
.LP
The \fBhosts\fR file has one entry for each IP address of each host. If a host
has more than one IP address, it will have one entry for each, on consecutive
lines. The format of each line is:
.sp
.LP
\fIIP-address\fR \fIofficial-host-name\fR \fInicknames\|.\|.\|\fR.
.sp
.LP
Items are separated by any number of \fBSPACE\fR and/or \fBTAB\fR characters.
The first item on a line is the host's IP address. The second entry is the
host's official name. Subsequent entries on the same line are alternative names
for the same machine, or "nicknames." Nicknames are optional.
.sp
.LP
For a host with more than one IP address, consecutive entries for these
addresses may contain the same or differing nicknames. Different nicknames are
useful for assigning distinct names to different addresses.
.sp
.LP
A call to \fBgethostbyname\fR(3NSL) returns a \fBhostent\fR structure
containing the union of all IPv4 addresses and nicknames from each line
containing a matching official name or nickname. A call to
\fBgetipnodebyname\fR(3SOCKET) is similar, but is capable of returning
\fBhostent\fR structures containing IPv4 and IPv6 addresses. Applications might
prefer to use the address-family independent \fBgetaddrinfo\fR(3SOCKET) API for
name-to-address lookups.
.sp
.LP
A `\fB#\fR' indicates the beginning of a comment; characters up to the end of
the line are not interpreted by routines that search the file.
.sp
.LP
Network addresses are written in one of two ways:
.RS +4
.TP
.ie t \(bu
.el o
The conventional "decimal dot" notation and interpreted using the
\fBinet_addr\fR routine from the Internet address manipulation library,
\fBinet\fR(3SOCKET).
.RE
.RS +4
.TP
.ie t \(bu
.el o
The IP Version 6 protocol [IPV6], defined in RFC 1884 and interpreted using the
\fBinet_pton()\fR routine from the Internet address manipulation library. See
\fBinet\fR(3SOCKET).
.RE
.sp
.LP
This interface supports node names as defined in Internet RFC 952, which
states:
.sp
.LP
A "name" (Net, Host, Gateway, or Domain name) is a text string up to 24
characters drawn from the alphabet (A-Z), digits (0-9), minus sign (\(mi), and
period (.). Note that periods are only allowed when they serve to delimit
components of "domain style names". (See RFC 921, "Domain Name System
Implementation Schedule," for background). No blank or space characters are
permitted as part of a name. No distinction is made between uppercase and
lowercase. The first character must be an alpha character [or a digit. (RFC
1123 relaxed RFC 952's limitation of the first character to only alpha
characters.)] The last character must not be a minus sign or period.
.sp
.LP
Host names must not consist of numbers only. A host name must contain at least
one alphabetical or special character.
.sp
.LP
Although the interface accepts host names longer than 24 characters for the
host portion (exclusive of the domain component), choosing names for hosts that
adhere to the 24 character restriction will insure maximum interoperability on
the Internet.
.sp
.LP
A host which serves as a GATEWAY should have "\(miGATEWAY" or "\(miGW" as part
of its name. Hosts which do not serve as Internet gateways should not use
"\(miGATEWAY" and "\(miGW" as part of their names. A host which is a TAC should
have "\(miTAC" as the last part of its host name, if it is a DoD host. Single
character names or nicknames are not allowed.
.SH EXAMPLES
.LP
\fBExample 1 \fRExample \fBhosts\fR File Entry
.sp
.LP
The following is a typical line from the \fBhosts\fR file:

.sp
.in +2
.nf
192.9.1.20        gaia                        # John Smith
.fi
.in -2
.sp

.LP
\fBExample 2 \fRExample IPv6 Address Entry
.sp
.LP
The following is an example of an IPv6 \fBhosts\fR entry:

.sp
.in +2
.nf
2001:0db8:3c4d:55:a00:20ff:fe8e:f3ad  myhost  # John Smith
.fi
.in -2
.sp

.SH SEE ALSO
.sp
.LP
\fBgethostbyname\fR(3NSL), \fBgetipnodebyname\fR(3SOCKET), \fBinet\fR(3SOCKET),
\fBnsswitch.conf\fR(4), \fBresolv.conf\fR(4)
.sp
.LP
Braden, B., editor, RFC 1123, \fIRequirements for Internet Hosts - Application
and Support\fR, Network Working Group, October, 1989.
.sp
.LP
Harrenstien, K., Stahl, M., and Feinler, E., RFC 952, \fIDOD Internet Host
Table Specification\fR, Network Working Group, October 1985.
.sp
.LP
Hinden, R., and Deering, S., editors, RFC 1884, \fIIP Version 6 Addressing
Architecture\fR, Network Working Group, December, 1995.
.sp
.LP
Postel, Jon, RFC 921, \fIDomain Name System Implementation Schedule
(Revised)\fR, Network Working Group, October 1984.
.SH NOTES
.sp
.LP
\fB/etc/inet/hosts\fR is the official SVR4 name of the \fBhosts\fR file. The
symbolic link \fB/etc/hosts\fR exists for \fBBSD\fR compatibility.
.sp
.LP
The symbolic link \fB/etc/net/ipnodes\fR exists for backwards compatibility
with previous Solaris releases.