| 1 |
.\" Copyright (c) 1987, 1990, 1993 |
| 2 |
.\" The Regents of the University of California. All rights reserved. |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: BSD-4-Clause-UC |
| 5 |
.\" |
| 6 |
.\" @(#)hostname.7 8.2 (Berkeley) 12/30/93 |
| 7 |
.\" $FreeBSD: src/share/man/man7/hostname.7,v 1.7 2004/07/03 18:29:23 ru Exp $ |
| 8 |
.\" |
| 9 |
.\" 2008-06-11, mtk, Taken from FreeBSD 6.2 and modified for Linux. |
| 10 |
.\" |
| 11 |
.TH hostname 7 2024-05-02 "Linux man-pages 6.9.1" |
| 12 |
.SH NAME |
| 13 |
hostname \- hostname resolution description |
| 14 |
.SH DESCRIPTION |
| 15 |
Hostnames are domains, where a domain is a hierarchical, dot-separated |
| 16 |
list of subdomains; for example, the machine "monet", in the "example" |
| 17 |
subdomain of the "com" domain would be represented as "monet.example.com". |
| 18 |
.P |
| 19 |
Each element of the hostname must be from 1 to 63 characters long and the |
| 20 |
entire hostname, including the dots, can be at most 253 characters long. |
| 21 |
Valid characters for hostnames are |
| 22 |
.BR ASCII (7) |
| 23 |
letters from |
| 24 |
.I a |
| 25 |
to |
| 26 |
.IR z , |
| 27 |
the digits from |
| 28 |
.I 0 |
| 29 |
to |
| 30 |
.IR 9 , |
| 31 |
and the hyphen (\-). |
| 32 |
A hostname may not start with a hyphen. |
| 33 |
.P |
| 34 |
Hostnames are often used with network client and server programs, |
| 35 |
which must generally translate the name to an address for use. |
| 36 |
(This task is generally performed by either |
| 37 |
.BR getaddrinfo (3) |
| 38 |
or the obsolete |
| 39 |
.BR gethostbyname (3).) |
| 40 |
.P |
| 41 |
Hostnames are resolved by the NSS framework in glibc according |
| 42 |
to the |
| 43 |
.B hosts |
| 44 |
configuration in |
| 45 |
.BR nsswitch.conf (5). |
| 46 |
The DNS-based name resolver |
| 47 |
(in the |
| 48 |
.B dns |
| 49 |
NSS service module) resolves them in the following fashion. |
| 50 |
.P |
| 51 |
If the name consists of a single component, that is, contains no dot, |
| 52 |
and if the environment variable |
| 53 |
.B HOSTALIASES |
| 54 |
is set to the name of a file, |
| 55 |
that file is searched for any string matching the input hostname. |
| 56 |
The file should consist of lines made up of two white-space separated strings, |
| 57 |
the first of which is the hostname alias, |
| 58 |
and the second of which is the complete hostname |
| 59 |
to be substituted for that alias. |
| 60 |
If a case-insensitive match is found between the hostname to be resolved |
| 61 |
and the first field of a line in the file, the substituted name is looked |
| 62 |
up with no further processing. |
| 63 |
.P |
| 64 |
If the input name ends with a trailing dot, |
| 65 |
the trailing dot is removed, |
| 66 |
and the remaining name is looked up with no further processing. |
| 67 |
.P |
| 68 |
If the input name does not end with a trailing dot, it is looked up |
| 69 |
by searching through a list of domains until a match is found. |
| 70 |
The default search list includes first the local domain, |
| 71 |
then its parent domains with at least 2 name components (longest first). |
| 72 |
For example, |
| 73 |
in the domain cs.example.com, the name lithium.cchem will be checked first |
| 74 |
as lithium.cchem.cs.example and then as lithium.cchem.example.com. |
| 75 |
lithium.cchem.com will not be tried, as there is only one component |
| 76 |
remaining from the local domain. |
| 77 |
The search path can be changed from the default |
| 78 |
by a system-wide configuration file (see |
| 79 |
.BR resolver (5)). |
| 80 |
.SH SEE ALSO |
| 81 |
.BR getaddrinfo (3), |
| 82 |
.BR gethostbyname (3), |
| 83 |
.BR nsswitch.conf (5), |
| 84 |
.BR resolver (5), |
| 85 |
.BR mailaddr (7), |
| 86 |
.BR named (8) |
| 87 |
.P |
| 88 |
.UR http://www.ietf.org\:/rfc\:/rfc1123.txt |
| 89 |
IETF RFC\ 1123 |
| 90 |
.UE |
| 91 |
.P |
| 92 |
.UR http://www.ietf.org\:/rfc\:/rfc1178.txt |
| 93 |
IETF RFC\ 1178 |
| 94 |
.UE |
| 95 |
.\" .SH HISTORY |
| 96 |
.\" Hostname appeared in |
| 97 |
.\" 4.2BSD. |