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 @@ + "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ + +%entities; +]> @@ -26,23 +29,65 @@ Description - The /etc/hostname file configures the - name of the local system that is set during boot using the - sethostname2 - 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. + The /etc/hostname file configures the name of the local system. Unless + overridden as described in the next section, + systemd1 will set this + hostname during boot using the + sethostname2 system + call. + + The file should contain a single newline-terminated hostname string. Comments (lines starting with + a #) 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. You may use - hostnamectl1 - to change the value of this file during runtime from the command - line. Use - systemd-firstboot1 - to initialize it on mounted (but not booted) system images. + hostnamectl1 to change + the value of this file during runtime from the command line. Use + systemd-firstboot1 to + initialize it on mounted (but not booted) system images. + + + + Hostname semantics + + systemd1 and the + associated tools will obtain the hostname in the following ways: + + If the kernel commandline parameter systemd.hostname= specifies a + valid hostname, + systemd1 will use it + to set the hostname during early boot, see + kernel-command-line7, + + + Otherwise, the "static" hostname specified by /etc/hostname as + described above will be used. + + Otherwise, a transient hostname may be set during runtime, for example based on + information in a DHCP lease, see + systemd-hostnamed.service8. + Both NetworkManager and + systemd-networkd.service8 + allow this. Note that + systemd-hostnamed.service8 + gives higher priority to the static hostname, so the transient hostname will only be used if the static + hostname is not configured. + + Otherwise, a fallback hostname configured at compilation time will be used + (&FALLBACK_HOSTNAME;). + + + + + 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. diff --git a/man/hostnamectl.xml b/man/hostnamectl.xml index 8c00867e73..f50cefa217 100644 --- a/man/hostnamectl.xml +++ b/man/hostnamectl.xml @@ -32,33 +32,23 @@ Description - hostnamectl may be used to query and - change the system hostname and related settings. + hostnamectl may be used to query and change the system hostname and related + settings. - This tool distinguishes three different hostnames: the - high-level "pretty" hostname which might include all kinds of - special characters (e.g. "Lennart's Laptop"), the static hostname - which is used to initialize the kernel hostname at boot (e.g. - "lennarts-laptop"), and the transient hostname which is a fallback - value received from network configuration. If a static hostname is - set, and is valid (something other than localhost), then the - transient hostname is not used. + systemd-hostnamed.service8 + and this tool distinguish three different hostnames: the high-level "pretty" hostname which might include + all kinds of special characters (e.g. "Lennart's Laptop"), the "static" hostname which is the + user-configured hostname (e.g. "lennarts-laptop"), and the transient hostname which is a fallback value + received from network configuration (e.g. "node12345678"). If a static hostname is set, and is valid + (something other than localhost), then the transient hostname is not used. Note that the pretty hostname has little restrictions on the characters and length used, while the static and transient hostnames are limited to the usually accepted characters of Internet domain names, and 64 characters at maximum (the latter being a Linux limitation). - The static hostname is stored in - /etc/hostname, see - hostname5 - for more information. The pretty hostname, chassis type, and icon - name are stored in /etc/machine-info, see - machine-info5. - Use - systemd-firstboot1 - to initialize the system hostname for mounted (but not booted) - system images. + systemd-firstboot1 to + initialize the system hostname for mounted (but not booted) system images. diff --git a/man/org.freedesktop.hostname1.xml b/man/org.freedesktop.hostname1.xml index f8e199ceaa..c715bad593 100644 --- a/man/org.freedesktop.hostname1.xml +++ b/man/org.freedesktop.hostname1.xml @@ -144,55 +144,53 @@ node /org/freedesktop/hostname1 { Semantics - The static (configured) hostname is the one configured in - /etc/hostname. It is chosen by the local user. It is not always in sync with the - current hostname as returned by the + The StaticHostname property exposes the "static" hostname configured in + /etc/hostname. It is not always in sync with the current hostname as returned by the gethostname3 - system call. If no hostname is configured this property will be the empty string. Setting this property - to the empty string will remove /etc/hostname. This property should be an - internet-style hostname, 7-bit lowercase ASCII, no special chars/spaces. + system call. If no static hostname is configured this property will be the empty string. - The transient (dynamic) hostname is the one configured via the kernel's + When systemd1 or + systemd-hostnamed.service8 + set the hostname, this static hostname has the highest priority. + + The Hostname property exposes the actual hostname configured in the kernel via sethostname3. - It can be different from the static hostname if DHCP or mDNS have been configured to change the name - based on network information. - This property is never empty. If no hostname is set this will default to - &FALLBACK_HOSTNAME; (configurable at compilation time). Setting this property to the - empty string will reset the dynamic hostname to the static hostname. If no static hostname is - configured the dynamic hostname will be reset to &FALLBACK_HOSTNAME;. This property - should be an internet-style hostname, 7-bit lowercase ASCII, no special chars/spaces. + It can be different from the static hostname. This property is never empty. - The pretty hostname is a free-form UTF-8 hostname for presentation to the - user. User interfaces should ensure that the pretty hostname and the static hostname stay in sync. - I.e. when the former is Lennart’s Computer the latter should be - lennarts-computer. If no pretty hostname is set this setting will be the empty - string. Applications should then find a suitable fallback, such as the dynamic hostname. + The PrettyHostname property exposes the pretty hostname + which is a free-form UTF-8 hostname for presentation to the user. User interfaces should ensure that the + pretty hostname and the static hostname stay in sync. E.g. when the former is Lennart’s + Computer the latter should be lennarts-computer. If no pretty hostname is + set this setting will be the empty string. Applications should then find a suitable fallback, such as the + dynamic hostname. - The icon name is a name following the XDG icon naming spec. If not set, - information such as the chassis type (see below) is used to find a suitable fallback icon name - (i.e. computer-laptop vs. computer-desktop is picked based on the - chassis information). If no such data is available, the empty string is returned. In that case an application - should fall back to a replacement icon, for example computer. If this property is set - to the empty string, the automatic fallback name selection is enabled again. + The IconName property exposes the icon name following the + XDG icon naming spec. If not set, information such as the chassis type (see below) is used to find a + suitable fallback icon name (i.e. computer-laptop + vs. computer-desktop is picked based on the chassis information). If no such data is + available, the empty string is returned. In that case an application should fall back to a replacement + icon, for example computer. If this property is set to the empty string, the automatic + fallback name selection is enabled again. - The chassis type should be one of the currently defined chassis types: - desktop, laptop, server, - tablet, handset, as well as the special chassis types - vm and container for virtualized systems. Note that in most cases - the chassis type will be determined automatically from DMI/SMBIOS/ACPI firmware information. Writing to - this setting is hence useful only to override misdetected chassis types, or to configure the chassis type if - it could not be auto-detected. Set this property to the empty string to reenable the automatic detection of - the chassis type from firmware information. + The Chassis property exposes a chassis type, one of the + currently defined chassis types: desktop, laptop, + server, tablet, handset, as well as the special + chassis types vm and container for virtualized systems. Note that + in most cases the chassis type will be determined automatically from DMI/SMBIOS/ACPI firmware + information. Writing to this setting is hence useful only to override misdetected chassis types, or to + configure the chassis type if it could not be auto-detected. Set this property to the empty string to + reenable the automatic detection of the chassis type from firmware information. Note that systemd-hostnamed starts only on request and terminates after a short idle period. This effectively means that PropertyChanged messages are not sent out for changes made directly on the files (as in: administrator edits the files with vi). This is the intended behavior: manual configuration changes should require manual reloading. - The transient (dynamic) hostname maps directly to the kernel hostname. This hostname should be - assumed to be highly dynamic, and hence should be watched directly, without depending on - PropertyChanged messages from systemd-hostnamed. To accomplish - this, open /proc/sys/kernel/hostname and + The transient (dynamic) hostname exposed by the Hostname property maps directly + to the kernel hostname. This hostname should be assumed to be highly dynamic, and hence should be watched + directly, without depending on PropertyChanged messages from + systemd-hostnamed. To accomplish this, open + /proc/sys/kernel/hostname and poll3 for SIGHUP which is triggered by the kernel every time the hostname changes. Again: this is special for the transient (dynamic) hostname, and does not apply to the configured (fixed) @@ -206,15 +204,17 @@ node /org/freedesktop/hostname1 { for that. For more information on these files and syscalls see the respective man pages. - Methods and Properties + Methods - SetHostname() sets the transient (dynamic) hostname which is exposed by the - Hostname property. If empty, the transient hostname is set to the static hostname. - + SetHostname() sets the transient (dynamic) hostname, which is used if no + static hostname is set. This value must be an internet-style hostname, 7-bit lowercase ASCII, no + special chars/spaces. An empty string will unset the transient hostname. SetStaticHostname() sets the static hostname which is exposed by the - StaticHostname property. If empty, the built-in default of - &FALLBACK_HOSTNAME; is used. + StaticHostname property. When called with an empty argument, the static + configuration in /etc/hostname is removed. Since the static hostname has the + highest priority, calling this function usually affects also the Hostname property + and the effective hostname configured in the kernel. SetPrettyHostname() sets the pretty hostname which is exposed by the PrettyHostname property. @@ -287,10 +287,6 @@ node /org/freedesktop/hostname1 { with nss-myhostname3. - A client that wants to change the local hostname for DHCP/mDNS should invoke - SetHostname("newname", false) as soon as the name is available and afterwards reset it via - SetHostname(""). - Here are some recommendations to follow when generating a static (internet) hostname from a pretty name: diff --git a/man/systemd-hostnamed.service.xml b/man/systemd-hostnamed.service.xml index c0c46b6609..0e42f671c2 100644 --- a/man/systemd-hostnamed.service.xml +++ b/man/systemd-hostnamed.service.xml @@ -51,9 +51,15 @@ + The static hostname is stored in /etc/hostname, see + hostname5 for more + information. The pretty hostname, chassis type, and icon name are stored in + /etc/machine-info, see + machine-info5. + The tool - hostnamectl1 - is a command line client to this service. + hostnamectl1 is a + command line client to this service. See org.freedesktop.hostname15