1*5bbd2a12Schristos.\" $NetBSD: hostname.7,v 1.1.1.2 2012/09/09 16:07:45 christos Exp $ 2b5677b36Schristos.\" 3b5677b36Schristos.\" Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") 4b5677b36Schristos.\" 5b5677b36Schristos.\" Permission to use, copy, modify, and/or distribute this software for any 6b5677b36Schristos.\" purpose with or without fee is hereby granted, provided that the above 7b5677b36Schristos.\" copyright notice and this permission notice appear in all copies. 8b5677b36Schristos.\" 9b5677b36Schristos.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10b5677b36Schristos.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11b5677b36Schristos.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12b5677b36Schristos.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13b5677b36Schristos.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14b5677b36Schristos.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15b5677b36Schristos.\" PERFORMANCE OF THIS SOFTWARE. 16b5677b36Schristos.\" 17b5677b36Schristos.\" Id: hostname.7,v 1.3 2009/01/22 23:49:23 tbox Exp 18b5677b36Schristos.\" 19b5677b36Schristos.Dd February 16, 1994 20b5677b36Schristos.Dt HOSTNAME @DESC_EXT_U@ 21b5677b36Schristos.Os BSD 4 22b5677b36Schristos.Sh NAME 23b5677b36Schristos.Nm hostname 24b5677b36Schristos.Nd host name resolution description 25b5677b36Schristos.Sh DESCRIPTION 26b5677b36SchristosHostnames are domains. A domain is a hierarchical, dot-separated list 27b5677b36Schristosof subdomains. For example, the machine 28b5677b36Schristos.Dq Li monet , 29b5677b36Schristosin the 30b5677b36Schristos.Dq Li Berkeley 31b5677b36Schristossubdomain of the 32b5677b36Schristos.Dq Li EDU 33b5677b36Schristossubdomain of the Internet Domain Name System would be represented as 34b5677b36Schristos.Pp 35b5677b36Schristos.Dl monet.Berkeley.EDU 36b5677b36Schristos.Pp 37b5677b36Schristos(with no trailing dot). 38b5677b36Schristos.Pp 39b5677b36SchristosHostnames are often used with network client and server programs, 40b5677b36Schristoswhich must generally translate the name to an address for use. 41b5677b36Schristos(This task is usually performed by the library routine 42b5677b36Schristos.Xr gethostbyname @LIB_NETWORK_EXT@ . ) 43b5677b36SchristosThe default method for resolving hostnames by the Internet name resolver is 44b5677b36Schristosto follow RFC 1535's security recommendations. Actions can be taken 45b5677b36Schristosby the administrator to override these recommendations and to have the 46b5677b36Schristosresolver behave the same as earlier, non-RFC 1535 47b5677b36Schristosresolvers. 48b5677b36Schristos.Pp 49b5677b36SchristosThe default method (using RFC 1535 guidelines) follows: 50b5677b36Schristos.Pp 51b5677b36SchristosIf the name consists of a single component, i.e. contains no dot, and if the 52b5677b36Schristosenvironment variable 53b5677b36Schristos.Dq Ev HOSTALIASES 54b5677b36Schristosis set to the name of a file, 55b5677b36Schristosthat file is searched for a string matching the input hostname. The file 56b5677b36Schristosshould consist of lines made up of two strings separated by white-space, the 57b5677b36Schristosfirst of which is the hostname alias, and the second of which is the complete 58b5677b36Schristoshostname to be substituted for that alias. If a case-insensitive match is 59b5677b36Schristosfound between the hostname to be resolved and the first field of a line in 60b5677b36Schristosthe file, the substituted name is looked up with no further processing. 61b5677b36Schristos.Pp 62b5677b36SchristosIf there is at least one dot in the name, then the name is first tried 63b5677b36Schristos.Dq as-is . 64b5677b36SchristosThe number of dots to cause this action is configurable by setting the 65b5677b36Schristosthreshold using the 66b5677b36Schristos.Dq Li ndots 67b5677b36Schristosoption in 68b5677b36Schristos.Pa /etc/resolv.conf 69b5677b36Schristos(default: 1). If the name ends with a dot, the trailing dot is 70b5677b36Schristosremoved, and the remaining name is looked up (regardless of the setting of 71b5677b36Schristosthe 72b5677b36Schristos.Li ndots 73b5677b36Schristosoption), without further processing. 74b5677b36Schristos.Pp 75b5677b36SchristosIf the input name does not end with a trailing dot, it is looked up by 76b5677b36Schristossearching through a list of domains until a match is found. If neither the 77b5677b36Schristossearch option in the 78b5677b36Schristos.Pa /etc/resolv.conf 79b5677b36Schristosfile or the 80b5677b36Schristos.Dq Ev LOCALDOMAIN 81b5677b36Schristosenvironment variable is used, then the 82b5677b36Schristossearch list of domains contains only the full domain specified by the 83b5677b36Schristos.Li domain 84b5677b36Schristosoption (in 85b5677b36Schristos.Pa /etc/resolv.conf ) 86b5677b36Schristosor the domain used in the local hostname. For example, if the 87b5677b36Schristos.Dq Li domain 88b5677b36Schristosoption is set to 89b5677b36Schristos.Li CS.Berkeley.EDU , 90b5677b36Schristosthen only 91b5677b36Schristos.Li CS.Berkeley.EDU 92b5677b36Schristoswill be in the search list, and this will be the only 93b5677b36Schristosdomain appended to the partial hostname. For example, if 94b5677b36Schristos.Dq Li lithium 95b5677b36Schristosis the name to be resolved, this would make 96b5677b36Schristos.Li lithium.CS.Berkeley.EDU 97b5677b36Schristosthe only name to be tried using the search list. 98b5677b36Schristos.Pp 99b5677b36SchristosIf the 100b5677b36Schristos.Li search 101b5677b36Schristosoption is used in 102b5677b36Schristos.Pa /etc/resolv.conf 103b5677b36Schristosor the environment variable 104b5677b36Schristos.Dq Ev LOCALDOMAIN 105b5677b36Schristosis set by the user, then 106b5677b36Schristosthe search list will include what is set by these methods. For 107b5677b36Schristosexample, if the 108b5677b36Schristos.Dq Li search 109b5677b36Schristosoption contained 110b5677b36Schristos.Pp 111b5677b36Schristos.Dl CS.Berkeley.EDU CChem.Berkeley.EDU Berkeley.EDU 112b5677b36Schristos.Pp 113b5677b36Schristosthen the partial hostname (e.g., 114b5677b36Schristos.Dq Li lithium ) 115b5677b36Schristoswill be tried with 116b5677b36Schristos.Em each 117b5677b36Schristosdomain name appended (in the same order specified); the resulting hostnames 118b5677b36Schristosthat would be tried are: 119b5677b36Schristos.Bd -literal -offset indent 120b5677b36Schristoslithium.CS.Berkeley.EDU 121b5677b36Schristoslithium.CChem.Berkeley.EDU 122b5677b36Schristoslithium.Berkeley.EDU 123b5677b36Schristos.Ed 124b5677b36Schristos.Pp 125b5677b36SchristosThe environment variable 126b5677b36Schristos.Dq Ev LOCALDOMAIN 127b5677b36Schristosoverrides the 128b5677b36Schristos.Dq Li search 129b5677b36Schristosand 130b5677b36Schristos.Dq Li domain 131b5677b36Schristosoptions, and if both 132b5677b36Schristos.Li search 133b5677b36Schristosand 134b5677b36Schristos.Li domain 135b5677b36Schristosoptions are present in the resolver configuration file, then only the 136b5677b36Schristos.Em last 137b5677b36Schristosone listed is used (see 138b5677b36Schristos.Xr resolver @FORMAT_EXT@ ) . 139b5677b36Schristos.Pp 140b5677b36SchristosIf the name was not previously tried 141b5677b36Schristos.Dq as-is 142b5677b36Schristos(i.e., it fell below the 143b5677b36Schristos.Dq Li ndots 144b5677b36Schristosthreshold or did not contain a dot), then the name as 145b5677b36Schristosoriginally provided is attempted. 146b5677b36Schristos.Sh ENVIRONMENT 147b5677b36Schristos.Bl -tag -width "/etc/resolv.conf " 148b5677b36Schristos.It Ev LOCALDOMAIN 149b5677b36SchristosAffects domains appended to partial hostnames. 150b5677b36Schristos.It Ev HOSTALIASES 151b5677b36SchristosName of file containing 152b5677b36Schristos.Pq Ar host alias , full hostname 153b5677b36Schristospairs. 154b5677b36Schristos.El 155b5677b36Schristos.Sh FILES 156b5677b36Schristos.Bl -tag -width "/etc/resolv.conf " -compact 157b5677b36Schristos.It Pa /etc/resolv.conf 158b5677b36SchristosSee 159b5677b36Schristos.Xr resolve @FORMAT_EXT@ . 160b5677b36Schristos.El 161b5677b36Schristos.Sh SEE ALSO 162b5677b36Schristos.Xr gethostbyname @LIB_NETWORK_EXT@ , 163b5677b36Schristos.Xr resolver @FORMAT_EXT@ , 164b5677b36Schristos.Xr mailaddr @DESC_EXT@ , 165