| 1 |
'\" t |
| 2 |
.TH "HOSTNAME" "5" "" "systemd 261~rc3" "hostname" |
| 3 |
.\" ----------------------------------------------------------------- |
| 4 |
.\" * Define some portability stuff |
| 5 |
.\" ----------------------------------------------------------------- |
| 6 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 7 |
.\" http://bugs.debian.org/507673 |
| 8 |
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
| 9 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 |
.ie \n(.g .ds Aq \(aq |
| 11 |
.el .ds Aq ' |
| 12 |
.\" ----------------------------------------------------------------- |
| 13 |
.\" * set default formatting |
| 14 |
.\" ----------------------------------------------------------------- |
| 15 |
.\" disable hyphenation |
| 16 |
.nh |
| 17 |
.\" disable justification (adjust text to left margin only) |
| 18 |
.ad l |
| 19 |
.\" ----------------------------------------------------------------- |
| 20 |
.\" * MAIN CONTENT STARTS HERE * |
| 21 |
.\" ----------------------------------------------------------------- |
| 22 |
.SH "NAME" |
| 23 |
hostname \- Local hostname configuration file |
| 24 |
.SH "SYNOPSIS" |
| 25 |
.PP |
| 26 |
/etc/hostname |
| 27 |
.SH "DESCRIPTION" |
| 28 |
.PP |
| 29 |
The |
| 30 |
/etc/hostname |
| 31 |
file configures the name of the local system\&. Unless overridden as described in the next section, |
| 32 |
\fBsystemd\fR(1) |
| 33 |
will set this hostname during boot using the |
| 34 |
\fBsethostname\fR(2) |
| 35 |
system call\&. |
| 36 |
.PP |
| 37 |
The file should contain a single newline\-terminated hostname string\&. Comments (lines starting with a |
| 38 |
"#") are ignored\&. The hostname should be composed of up to 64 7\-bit ASCII lower\-case alphanumeric characters or hyphens forming a valid DNS domain name\&. It is strongly recommended that this name contains only a single DNS label, i\&.e does not contain any dots\&. This recommendation reflects both usual expectations of applications, and the fact that the Linux kernel limits the length of the system hostname to 64 (i\&.e\&. close to the maximum DNS label length of 63) rather than 255 (the maximum DNS domain name length)\&. When applied, invalid characters will be filtered out in an attempt to make the name valid, but obviously it is recommended to use a valid name and not rely on this filtering\&. |
| 39 |
.PP |
| 40 |
If the question mark character |
| 41 |
"?" |
| 42 |
appears in the hostname, it is automatically substituted by a hexadecimal character derived from the |
| 43 |
\fBmachine-id\fR(5) |
| 44 |
when applied, securely and deterministically by cryptographic hashing\&. Example: |
| 45 |
"foobar\-????\-????" |
| 46 |
will automatically expand to |
| 47 |
"foobar\-92a9\-061c" |
| 48 |
or similar, depending on the local machine ID\&. |
| 49 |
.PP |
| 50 |
You may use |
| 51 |
\fBhostnamectl\fR(1) |
| 52 |
to change the value of this file during runtime from the command line\&. Use |
| 53 |
\fBsystemd-firstboot\fR(1) |
| 54 |
to initialize it on mounted (but not booted) system images\&. |
| 55 |
.SH "HOSTNAME SEMANTICS" |
| 56 |
.PP |
| 57 |
\fBsystemd\fR(1) |
| 58 |
and the associated tools will obtain the hostname in the following ways: |
| 59 |
.sp |
| 60 |
.RS 4 |
| 61 |
.ie n \{\ |
| 62 |
\h'-04'\(bu\h'+03'\c |
| 63 |
.\} |
| 64 |
.el \{\ |
| 65 |
.sp -1 |
| 66 |
.IP \(bu 2.3 |
| 67 |
.\} |
| 68 |
If the kernel command line parameter |
| 69 |
\fIsystemd\&.hostname=\fR |
| 70 |
specifies a valid hostname, |
| 71 |
\fBsystemd\fR(1) |
| 72 |
will use it to set the hostname during early boot, see |
| 73 |
\fBkernel-command-line\fR(7), |
| 74 |
.RE |
| 75 |
.sp |
| 76 |
.RS 4 |
| 77 |
.ie n \{\ |
| 78 |
\h'-04'\(bu\h'+03'\c |
| 79 |
.\} |
| 80 |
.el \{\ |
| 81 |
.sp -1 |
| 82 |
.IP \(bu 2.3 |
| 83 |
.\} |
| 84 |
Otherwise, the "static" hostname specified by |
| 85 |
/etc/hostname |
| 86 |
as described above will be used\&. |
| 87 |
.RE |
| 88 |
.sp |
| 89 |
.RS 4 |
| 90 |
.ie n \{\ |
| 91 |
\h'-04'\(bu\h'+03'\c |
| 92 |
.\} |
| 93 |
.el \{\ |
| 94 |
.sp -1 |
| 95 |
.IP \(bu 2.3 |
| 96 |
.\} |
| 97 |
Otherwise, a transient hostname may be set during runtime, for example based on information in a DHCP lease, see |
| 98 |
\fBsystemd-hostnamed.service\fR(8)\&. Both |
| 99 |
\m[blue]\fBNetworkManager\fR\m[]\&\s-2\u[1]\d\s+2 |
| 100 |
and |
| 101 |
\fBsystemd-networkd.service\fR(8) |
| 102 |
allow this\&. Note that |
| 103 |
\fBsystemd-hostnamed.service\fR(8) |
| 104 |
gives higher priority to the static hostname, so the transient hostname will only be used if the static hostname is not configured\&. |
| 105 |
.RE |
| 106 |
.sp |
| 107 |
.RS 4 |
| 108 |
.ie n \{\ |
| 109 |
\h'-04'\(bu\h'+03'\c |
| 110 |
.\} |
| 111 |
.el \{\ |
| 112 |
.sp -1 |
| 113 |
.IP \(bu 2.3 |
| 114 |
.\} |
| 115 |
Otherwise, a fallback hostname configured at compilation time will be used ("localhost")\&. |
| 116 |
.RE |
| 117 |
.PP |
| 118 |
Effectively, the static hostname has higher priority than a transient hostname, which has higher priority than the fallback hostname\&. Transient hostnames are equivalent, so setting a new transient hostname causes the previous transient hostname to be forgotten\&. The hostname specified on the kernel command line is like a transient hostname, with the exception that it has higher priority when the machine boots\&. Also note that those are the semantics implemented by systemd tools, but other programs may also set the hostname\&. |
| 119 |
.SH "HISTORY" |
| 120 |
.PP |
| 121 |
The simple configuration file format of |
| 122 |
/etc/hostname |
| 123 |
originates from Debian GNU/Linux\&. |
| 124 |
.SH "SEE ALSO" |
| 125 |
.PP |
| 126 |
\fBsystemd\fR(1), \fBsethostname\fR(2), \fBhostname\fR(1), \fBhostname\fR(7), \fBmachine-id\fR(5), \fBmachine-info\fR(5), \fBhostnamectl\fR(1), \fBsystemd-hostnamed.service\fR(8), \fBsystemd-firstboot\fR(1) |
| 127 |
.SH "NOTES" |
| 128 |
.IP " 1." 4 |
| 129 |
NetworkManager |
| 130 |
.RS 4 |
| 131 |
\%https://developer.gnome.org/NetworkManager/stable/ |
| 132 |
.RE |