Debian Codegraph @

upstream/debian-unstable/man7/hostname.7

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