summaryrefslogtreecommitdiff
path: root/man/hostname.xml
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-04 15:16:24 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-16 10:54:57 +0100
commitde31bbc6b1689322c982908ec90adf8c7778b05f (patch)
tree61e3848581bcd310382c88f64bda5e9860b00a78 /man/hostname.xml
parenta2be8be2cf5b7e5f74edcd7bbd4640d01f39bae2 (diff)
downloadsystemd-de31bbc6b1689322c982908ec90adf8c7778b05f.tar.gz
man/hostnamectl,hostaned,hostname1: adjust the docs to match reality
The semantics were significantly changed in c779a44222161155c039a7fd2fd304c006590ac7 ("hostnamed: Fix the way that static and transient host names interact", Feb. 2014), but when the dbus api documentation was imported much later, it wasn't properly adjusted to describe those new semantics. 34293dfafd2a81d80727938199769906dab321bd which added systemd.hostname= also added new behaviour. Let's ove various bits and pieces around so that they are in more appropriate places. Drop recommendations to set the hostname for DHCP or mDNS purposes. Nowadays we expect tools that want to expose some different hostname to the outside to manage that internally without affecting visible state. Also drop mentions of DHCP or mDNS directly setting the hostname, since nowadays network management software is expected to (and does) go through hostnamed. Also, add a high-level description of semantics. It glosses over the details of handling of localhost-style names. Later commits will remove this special handling anyway.
Diffstat (limited to 'man/hostname.xml')
-rw-r--r--man/hostname.xml77
1 files changed, 61 insertions, 16 deletions
diff --git a/man/hostname.xml b/man/hostname.xml
index edbeef8f4a..d050703792 100644
--- a/man/hostname.xml
+++ b/man/hostname.xml
@@ -1,6 +1,9 @@
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
+<!ENTITY % entities SYSTEM "custom-entities.ent" >
+%entities;
+]>
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
<refentry id="hostname">
@@ -26,23 +29,65 @@
<refsect1>
<title>Description</title>
- <para>The <filename>/etc/hostname</filename> file configures the
- name of the local system that is set during boot using the
- <citerefentry><refentrytitle>sethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
- system call. It should contain a single newline-terminated
- hostname string. Comments (lines starting with a `#') are ignored.
- The hostname may be a free-form string up to 64 characters in length;
- however, it is recommended that it consists only of 7-bit ASCII lower-case
- characters and no spaces or dots, and limits itself to the format allowed
- for DNS domain name labels, even though this is not a strict
- requirement.</para>
+ <para>The <filename>/etc/hostname</filename> file configures the name of the local system. Unless
+ overridden as described in the next section,
+ <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> will set this
+ hostname during boot using the
+ <citerefentry><refentrytitle>sethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry> system
+ call.</para>
+
+ <para>The file should contain a single newline-terminated hostname string. Comments (lines starting with
+ a <literal>#</literal>) 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 recommended that this name
+ contains only a single label, i.e. without any dots. 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.</para>
<para>You may use
- <citerefentry><refentrytitle>hostnamectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
- to change the value of this file during runtime from the command
- line. Use
- <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>
- to initialize it on mounted (but not booted) system images.</para>
+ <citerefentry><refentrytitle>hostnamectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to change
+ the value of this file during runtime from the command line. Use
+ <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry> to
+ initialize it on mounted (but not booted) system images.</para>
+ </refsect1>
+
+ <refsect1>
+ <title>Hostname semantics</title>
+
+ <para><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> and the
+ associated tools will obtain the hostname in the following ways:</para>
+ <itemizedlist>
+ <listitem><para>If the kernel commandline parameter <varname>systemd.hostname=</varname> specifies a
+ valid hostname,
+ <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> will use it
+ to set the hostname during early boot, see
+ <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
+ </para></listitem>
+
+ <listitem><para>Otherwise, the "static" hostname specified by <filename>/etc/hostname</filename> as
+ described above will be used.</para></listitem>
+
+ <listitem><para>Otherwise, a transient hostname may be set during runtime, for example based on
+ information in a DHCP lease, see
+ <citerefentry><refentrytitle>systemd-hostnamed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
+ Both <ulink url="https://developer.gnome.org/NetworkManager/stable/">NetworkManager</ulink> and
+ <citerefentry><refentrytitle>systemd-networkd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ allow this. Note that
+ <citerefentry><refentrytitle>systemd-hostnamed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ gives higher priority to the static hostname, so the transient hostname will only be used if the static
+ hostname is not configured.</para></listitem>
+
+ <listitem><para>Otherwise, a fallback hostname configured at compilation time will be used
+ (<literal>&FALLBACK_HOSTNAME;</literal>).</para></listitem>
+
+ <!-- what about the "linux" fallback fallback? -->
+ </itemizedlist>
+
+ <para>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.</para>
</refsect1>
<refsect1>