xref: /netbsd-src/share/man/man7/hostname.7 (revision e255887aeb479960790bb4981d2608cabd53201e)
1*e255887aSwiz.\" $NetBSD: hostname.7,v 1.13 2012/03/29 18:37:21 wiz Exp $
20bf49d4fSwiz.\"
3c12b4b55Schristos.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
4294d9cc7Sjtc.\"
5c12b4b55Schristos.\" Permission to use, copy, modify, and distribute this software for any
6c12b4b55Schristos.\" purpose with or without fee is hereby granted, provided that the above
7c12b4b55Schristos.\" copyright notice and this permission notice appear in all copies.
861f28255Scgd.\"
9c12b4b55Schristos.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10c12b4b55Schristos.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11c12b4b55Schristos.\" MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
12c12b4b55Schristos.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13c12b4b55Schristos.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14c12b4b55Schristos.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15c12b4b55Schristos.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1661f28255Scgd.\"
17c12b4b55Schristos.\" Copyright (c) 1987 The Regents of the University of California.
18c12b4b55Schristos.\" All rights reserved.
1961f28255Scgd.\"
20c12b4b55Schristos.\" Redistribution and use in source and binary forms are permitted
21c12b4b55Schristos.\" provided that the above copyright notice and this paragraph are
22c12b4b55Schristos.\" duplicated in all such forms and that any documentation,
23c12b4b55Schristos.\" advertising materials, and other materials related to such
24c12b4b55Schristos.\" distribution and use acknowledge that the software was developed
25c12b4b55Schristos.\" by the University of California, Berkeley.  The name of the
26c12b4b55Schristos.\" University may not be used to endorse or promote products derived
27c12b4b55Schristos.\" from this software without specific prior written permission.
28c12b4b55Schristos.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
29c12b4b55Schristos.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
30c12b4b55Schristos.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
3161f28255Scgd.\"
32c12b4b55Schristos.\"	@(#)hostname.7	6.4 (Berkeley) 1/16/90
33c12b4b55Schristos.\"
34c12b4b55Schristos.Dd February 16, 1994
3561f28255Scgd.Dt HOSTNAME 7
360bf49d4fSwiz.Os
3761f28255Scgd.Sh NAME
3861f28255Scgd.Nm hostname
3961f28255Scgd.Nd host name resolution description
4061f28255Scgd.Sh DESCRIPTION
410bf49d4fSwizHostnames are domains.
420bf49d4fSwizA domain is a hierarchical, dot-separated list of subdomains.
430bf49d4fSwizFor example, the machine
44c12b4b55Schristos.Dq Li monet ,
45c12b4b55Schristosin the
46c12b4b55Schristos.Dq Li Berkeley
47c12b4b55Schristossubdomain of the
48c12b4b55Schristos.Dq Li EDU
49c12b4b55Schristossubdomain of the Internet Domain Name System would be represented as
5061f28255Scgd.Pp
5161f28255Scgd.Dl monet.Berkeley.EDU
5261f28255Scgd.Pp
5361f28255Scgd(with no trailing dot).
5461f28255Scgd.Pp
5561f28255ScgdHostnames are often used with network client and server programs,
5661f28255Scgdwhich must generally translate the name to an address for use.
57c12b4b55Schristos(This task is usually performed by the library routine
5861f28255Scgd.Xr gethostbyname 3 . )
59c12b4b55SchristosThe default method for resolving hostnames by the Internet name resolver is
600bf49d4fSwizto follow RFC 1535's security recommendations.
610bf49d4fSwizActions can be taken by the administrator to override these
620bf49d4fSwizrecommendations and to have the resolver behave the same as earlier,
630bf49d4fSwiznon-RFC 1535 resolvers.
6461f28255Scgd.Pp
65c12b4b55SchristosThe default method (using RFC 1535 guidelines) follows:
66c12b4b55Schristos.Pp
67c12b4b55SchristosIf the name consists of a single component, i.e. contains no dot, and if the
68c12b4b55Schristosenvironment variable
6961f28255Scgd.Dq Ev HOSTALIASES
7061f28255Scgdis set to the name of a file,
710bf49d4fSwizthat file is searched for a string matching the input hostname.
720bf49d4fSwizThe file
73c12b4b55Schristosshould consist of lines made up of two strings separated by white-space, the
74c12b4b55Schristosfirst of which is the hostname alias, and the second of which is the complete
750bf49d4fSwizhostname to be substituted for that alias.
760bf49d4fSwizIf a case-insensitive match is
77c12b4b55Schristosfound between the hostname to be resolved and the first field of a line in
78c12b4b55Schristosthe file, the substituted name is looked up with no further processing.
7961f28255Scgd.Pp
80c12b4b55SchristosIf there is at least one dot in the name, then the name is first tried
81c12b4b55Schristos.Dq as-is .
82c12b4b55SchristosThe number of dots to cause this action is configurable by setting the
83c12b4b55Schristosthreshold using the
84c12b4b55Schristos.Dq Li ndots
85c12b4b55Schristosoption in
86c12b4b55Schristos.Pa /etc/resolv.conf
870bf49d4fSwiz(default: 1).
880bf49d4fSwizIf the name ends with a dot, the trailing dot is
89c12b4b55Schristosremoved, and the remaining name is looked up (regardless of the setting of
90c12b4b55Schristosthe
91c12b4b55Schristos.Li ndots
92c12b4b55Schristosoption), without further processing.
9361f28255Scgd.Pp
94c12b4b55SchristosIf the input name does not end with a trailing dot, it is looked up by
950bf49d4fSwizsearching through a list of domains until a match is found.
960bf49d4fSwizIf neither the search option in the
97c12b4b55Schristos.Pa /etc/resolv.conf
98c12b4b55Schristosfile or the
99c12b4b55Schristos.Dq Ev LOCALDOMAIN
100c12b4b55Schristosenvironment variable is used, then the
101c12b4b55Schristossearch list of domains contains only the full domain specified by the
102c12b4b55Schristos.Li domain
103c12b4b55Schristosoption (in
104c12b4b55Schristos.Pa /etc/resolv.conf )
1050bf49d4fSwizor the domain used in the local hostname.
1060bf49d4fSwizFor example, if the
107c12b4b55Schristos.Dq Li domain
108c12b4b55Schristosoption is set to
109c12b4b55Schristos.Li CS.Berkeley.EDU ,
110c12b4b55Schristosthen only
111c12b4b55Schristos.Li CS.Berkeley.EDU
112c12b4b55Schristoswill be in the search list, and this will be the only
1130bf49d4fSwizdomain appended to the partial hostname.
1140bf49d4fSwizFor example, if
115c12b4b55Schristos.Dq Li lithium
116c12b4b55Schristosis the name to be resolved, this would make
117c12b4b55Schristos.Li lithium.CS.Berkeley.EDU
118c12b4b55Schristosthe only name to be tried using the search list.
119c12b4b55Schristos.Pp
120c12b4b55SchristosIf the
121c12b4b55Schristos.Li search
122c12b4b55Schristosoption is used in
123c12b4b55Schristos.Pa /etc/resolv.conf
124c12b4b55Schristosor the environment variable
125c12b4b55Schristos.Dq Ev LOCALDOMAIN
126c12b4b55Schristosis set by the user, then
1270bf49d4fSwizthe search list will include what is set by these methods.
1280bf49d4fSwizFor example, if the
129c12b4b55Schristos.Dq Li search
130c12b4b55Schristosoption contained
131c12b4b55Schristos.Pp
132c12b4b55Schristos.Dl CS.Berkeley.EDU CChem.Berkeley.EDU Berkeley.EDU
133c12b4b55Schristos.Pp
134c12b4b55Schristosthen the partial hostname (e.g.,
135c12b4b55Schristos.Dq Li lithium )
136c12b4b55Schristoswill be tried with
137c12b4b55Schristos.Em each
138c12b4b55Schristosdomain name appended (in the same order specified); the resulting hostnames
139c12b4b55Schristosthat would be tried are:
140c12b4b55Schristos.Bd -literal -offset indent
141c12b4b55Schristoslithium.CS.Berkeley.EDU
142c12b4b55Schristoslithium.CChem.Berkeley.EDU
143c12b4b55Schristoslithium.Berkeley.EDU
144c12b4b55Schristos.Ed
145c12b4b55Schristos.Pp
146c12b4b55SchristosThe environment variable
147c12b4b55Schristos.Dq Ev LOCALDOMAIN
148c12b4b55Schristosoverrides the
149c12b4b55Schristos.Dq Li search
150c12b4b55Schristosand
151c12b4b55Schristos.Dq Li domain
152c12b4b55Schristosoptions, and if both
153c12b4b55Schristos.Li search
154c12b4b55Schristosand
155c12b4b55Schristos.Li domain
156c12b4b55Schristosoptions are present in the resolver configuration file, then only the
157c12b4b55Schristos.Em last
158c12b4b55Schristosone listed is used (see
159*e255887aSwiz.Xr resolv.conf 5 ) .
160c12b4b55Schristos.Pp
161c12b4b55SchristosIf the name was not previously tried
162c12b4b55Schristos.Dq as-is
163c12b4b55Schristos(i.e., it fell below the
164c12b4b55Schristos.Dq Li ndots
165c12b4b55Schristosthreshold or did not contain a dot), then the name as
166c12b4b55Schristosoriginally provided is attempted.
167c12b4b55Schristos.Sh ENVIRONMENT
168c12b4b55Schristos.Bl -tag -width "/etc/resolv.conf  "
169c12b4b55Schristos.It Ev LOCALDOMAIN
170c12b4b55SchristosAffects domains appended to partial hostnames.
171c12b4b55Schristos.It Ev HOSTALIASES
172c12b4b55SchristosName of file containing
173c12b4b55Schristos.Pq Ar host alias , full hostname
174c12b4b55Schristospairs.
175c12b4b55Schristos.El
176c12b4b55Schristos.Sh FILES
177c12b4b55Schristos.Bl -tag -width "/etc/resolv.conf  " -compact
178c12b4b55Schristos.It Pa /etc/resolv.conf
179c12b4b55SchristosSee
180*e255887aSwiz.Xr resolv.conf 5 .
181c12b4b55Schristos.El
18261f28255Scgd.Sh SEE ALSO
18361f28255Scgd.Xr gethostbyname 3 ,
184*e255887aSwiz.Xr resolv.conf 5 ,
1850bf49d4fSwiz.Xr mailaddr 7
186