2013-01-05 17:39:09 +00:00
|
|
|
<?xml version='1.0'?> <!--*-nxml-*-->
|
2019-03-14 13:40:58 +00:00
|
|
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
2023-12-25 14:48:33 +00:00
|
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
2020-11-09 04:23:58 +00:00
|
|
|
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
|
2013-01-05 17:39:09 +00:00
|
|
|
|
2018-07-18 00:25:57 +00:00
|
|
|
<refentry id="nss-myhostname" conditional='ENABLE_NSS_MYHOSTNAME'>
|
2013-01-05 17:39:09 +00:00
|
|
|
|
2015-02-04 02:14:13 +00:00
|
|
|
<refentryinfo>
|
|
|
|
<title>nss-myhostname</title>
|
|
|
|
<productname>systemd</productname>
|
|
|
|
</refentryinfo>
|
|
|
|
|
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>nss-myhostname</refentrytitle>
|
|
|
|
<manvolnum>8</manvolnum>
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>nss-myhostname</refname>
|
|
|
|
<refname>libnss_myhostname.so.2</refname>
|
2020-07-06 08:49:59 +00:00
|
|
|
<refpurpose>Hostname resolution for the locally configured system hostname</refpurpose>
|
2015-02-04 02:14:13 +00:00
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
<para><filename>libnss_myhostname.so.2</filename></para>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
|
2016-02-23 17:24:03 +00:00
|
|
|
<para><command>nss-myhostname</command> is a plug-in module for the GNU Name Service Switch (NSS) functionality of
|
|
|
|
the GNU C Library (<command>glibc</command>), primarily providing hostname resolution for the locally configured
|
|
|
|
system hostname as returned by
|
|
|
|
<citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>. The precise
|
|
|
|
hostnames resolved by this module are:</para>
|
2015-02-04 02:14:13 +00:00
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem><para>The local, configured hostname is resolved to
|
|
|
|
all locally configured IP addresses ordered by their scope, or
|
|
|
|
— if none are configured — the IPv4 address 127.0.0.2 (which
|
|
|
|
is on the local loopback) and the IPv6 address ::1 (which is the
|
|
|
|
local host).</para></listitem>
|
|
|
|
|
2016-02-19 03:31:38 +00:00
|
|
|
<listitem><para>The hostnames <literal>localhost</literal> and
|
|
|
|
<literal>localhost.localdomain</literal> (as well as any hostname
|
|
|
|
ending in <literal>.localhost</literal> or <literal>.localhost.localdomain</literal>)
|
|
|
|
are resolved to the IP addresses 127.0.0.1 and ::1.</para></listitem>
|
2015-02-04 02:14:13 +00:00
|
|
|
|
2017-10-13 07:10:26 +00:00
|
|
|
<listitem><para>The hostname <literal>_gateway</literal> is
|
2015-02-04 02:14:13 +00:00
|
|
|
resolved to all current default routing gateway addresses,
|
|
|
|
ordered by their metric. This assigns a stable hostname to the
|
|
|
|
current gateway, useful for referencing it independently of the
|
|
|
|
current network configuration state.</para></listitem>
|
2021-03-26 17:40:52 +00:00
|
|
|
|
|
|
|
<listitem><para>The hostname <literal>_outbound</literal> is resolved to the local IPv4 and IPv6
|
|
|
|
addresses that are most likely used for communication with other hosts. This is determined by
|
|
|
|
requesting a routing decision to the configured default gateways from the kernel and then using the
|
|
|
|
local IP addresses selected by this decision. This hostname is only available if there is at least one
|
|
|
|
local default gateway configured. This assigns a stable hostname to the local outbound IP addresses,
|
|
|
|
useful for referencing them independently of the current network configuration state.</para></listitem>
|
2015-02-04 02:14:13 +00:00
|
|
|
</itemizedlist>
|
|
|
|
|
|
|
|
<para>Various software relies on an always-resolvable local
|
|
|
|
hostname. When using dynamic hostnames, this is traditionally
|
|
|
|
achieved by patching <filename>/etc/hosts</filename> at the same
|
|
|
|
time as changing the hostname. This is problematic since it
|
2020-10-05 16:08:21 +00:00
|
|
|
requires a writable <filename>/etc/</filename> file system and is
|
2015-02-04 02:14:13 +00:00
|
|
|
fragile because the file might be edited by the administrator at
|
2014-08-03 05:11:12 +00:00
|
|
|
the same time. With <command>nss-myhostname</command> enabled,
|
2015-05-11 11:49:29 +00:00
|
|
|
changing <filename>/etc/hosts</filename> is unnecessary, and on
|
2014-08-03 05:11:12 +00:00
|
|
|
many systems, the file becomes entirely optional.</para>
|
2015-02-04 02:14:13 +00:00
|
|
|
|
2016-02-23 17:24:03 +00:00
|
|
|
<para>To activate the NSS modules, add <literal>myhostname</literal> to the line starting with
|
|
|
|
<literal>hosts:</literal> in <filename>/etc/nsswitch.conf</filename>.</para>
|
2015-02-04 02:14:13 +00:00
|
|
|
|
2021-07-01 20:11:27 +00:00
|
|
|
<para>It is recommended to place <literal>myhostname</literal> after <literal>file</literal> and before <literal>dns</literal>.
|
|
|
|
This resolves well-known hostnames like <literal>localhost</literal>
|
|
|
|
and the machine hostnames locally. It is consistent with the behaviour
|
|
|
|
of <command>nss-resolve</command>, and still allows overriding via
|
2021-07-17 17:49:42 +00:00
|
|
|
<filename>/etc/hosts</filename>.</para>
|
|
|
|
|
|
|
|
<para>Please keep in mind that <command>nss-myhostname</command> (and <command>nss-resolve</command>) also resolve
|
2021-08-18 10:14:31 +00:00
|
|
|
in the other direction — from locally attached IP addresses to
|
2021-07-17 17:49:42 +00:00
|
|
|
hostnames. If you rely on that lookup being provided by DNS, you might
|
|
|
|
want to order things differently.
|
2021-07-01 20:11:27 +00:00
|
|
|
</para>
|
2015-02-04 02:14:13 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Example</title>
|
|
|
|
|
2016-02-23 17:24:03 +00:00
|
|
|
<para>Here is an example <filename>/etc/nsswitch.conf</filename> file that enables
|
|
|
|
<command>nss-myhostname</command> correctly:</para>
|
2015-02-04 02:14:13 +00:00
|
|
|
|
2018-11-27 16:02:20 +00:00
|
|
|
<!-- synchronize with other nss-* man pages and factory/etc/nsswitch.conf -->
|
2023-09-20 09:50:20 +00:00
|
|
|
<programlisting>passwd: files systemd
|
|
|
|
group: files [SUCCESS=merge] systemd
|
|
|
|
shadow: files systemd
|
2021-05-05 14:11:26 +00:00
|
|
|
gshadow: files systemd
|
|
|
|
|
2020-08-17 07:10:32 +00:00
|
|
|
hosts: mymachines resolve [!UNAVAIL=return] files <command>myhostname</command> dns
|
2013-01-05 17:39:09 +00:00
|
|
|
networks: files
|
|
|
|
|
|
|
|
protocols: db files
|
|
|
|
services: db files
|
2015-08-26 09:00:09 +00:00
|
|
|
ethers: db files
|
|
|
|
rpc: db files
|
2013-01-05 17:39:09 +00:00
|
|
|
|
2014-02-14 14:56:19 +00:00
|
|
|
netgroup: nis</programlisting>
|
2013-01-05 17:39:09 +00:00
|
|
|
|
man: fix issues reported by the manpage-l10n project
Fixes #25780.
> Man page: crypttab.5
> Issue 1: Missing fullstop
> Issue 2: I<cipher=>, I<hash=>, I<size=> → B<cipher=>, B<hash=>, B<size=>
>
> "Force LUKS mode\\&. When this mode is used, the following options are "
> "ignored since they are provided by the LUKS header on the device: "
> "I<cipher=>, I<hash=>, I<size=>"
Seems OK to me. The full stop is there and has been for at least a few years. And we use <option> for the markup, which is appropriate here.
> Man page: crypttab.5
> Issue 1: Missing fullstop
> Issue 2: I<cipher=>, I<hash=>, I<keyfile-offset=>, I<keyfile-size=>, I<size=> → B<cipher=>, B<hash=>, B<keyfile-offset=>, B<keyfile-size=>, B<size=>
>
> "Use TrueCrypt encryption mode\\&. When this mode is used, the following "
> "options are ignored since they are provided by the TrueCrypt header on the "
> "device or do not apply: I<cipher=>, I<hash=>, I<keyfile-offset=>, I<keyfile-"
> "size=>, I<size=>"
Same.
> Man page: journalctl.1
> Issue 1: make be → may be
Fixed.
> Issue 2: below\\&. → below:
Fixed.
> Man page: journalctl.1
> Issue: Colon at the end?
>
> "The following commands are understood\\&. If none is specified the default "
> "is to display journal records\\&."
> msgstr ""
> "Die folgenden Befehle werden verstanden\\&. Falls keiner festgelegt ist, ist "
> "die Anzeige von Journal-Datensätzen die Vorgabe\\&."
This is a bit awkward, but I'm not sure how to fix it.
> Man page: kernel-install.8
> Issue: methods a fallback → methods fallback
It was correct, but I added a comma to make the sense clearer.
> Man page: loader.conf.5
> Issue 1: secure boot variables → Secure Boot variables
> Issue 2: one → one for (multiple times)
>
> "Supported secure boot variables are one database for authorized images, one "
> "key exchange key (KEK) and one platform key (PK)\\&. For more information, "
> "refer to the \\m[blue]B<UEFI specification>\\m[]\\&\\s-2\\u[2]\\d\\s+2, "
> "under Secure Boot and Driver Signing\\&. Another resource that describe the "
> "interplay of the different variables is the \\m[blue]B<EDK2 "
> "documentation>\\m[]\\&\\s-2\\u[3]\\d\\s+2\\&."
"one of" would sound strange. "One this and one that" is OK.
> Man page: loader.conf.5
> Issue: systemd-boot → B<systemd-boot>(7)
Fixed.
> Man page: logind.conf.5
> Issue: systemd-logind → B<systemd-logind>(8)
We use <filename>systemd-logind</> on subsequent references… I think that's good enough.
> Man page: nss-myhostname.8
> Issue: B<getent> → B<getent>(1)
Fixed.
> Man page: nss-resolve.8
> Issue: B<systemd-resolved> → B<systemd-resolved>(8)
The first reference does this, subsequent are shorter.
> Man page: os-release.5
> Issue: Portable Services → Portable Services Documentation?
Updated.
> Man page: pam_systemd_home.8
> Issue: auth and account use "reason", while session and password do not?
Reworded.
> Man page: portablectl.1
> Issue: In systemd-portabled.service(8): Portable Services Documentation
Updated.
> Man page: repart.d.5
> Issue: The partition → the partition
Fixed.
> Man page: repart.d.5
> Issue: B<systemd-repart> → B<systemd-repart>(8)
The first reference does this. I also change this one, because it's pretty far down in the text.
> Man page: systemd.1
> Issue: kernel command line twice?
>
> "Takes a boolean argument\\&. If false disables importing credentials from "
> "the kernel command line, qemu_fw_cfg subsystem or the kernel command line\\&."
Apparently this was fixed already.
> Man page: systemd-boot.7
> Issue: enrollement → enrollment
Fixed.
> Man page: systemd-cryptenroll.1
> Issue: multiple cases: any specified → the specified
Reworded.
> Man page: systemd-cryptenroll.1
> Issue: If this this → If this
Fixed tree-wide.
> Man page: systemd-cryptsetup-generator.8
> Issue: and the initrd → and in the initrd
"Is honoured by the initrd" is OK, because we often speak about the initrd as a single unit. But in the same paragraph we also used "in the initrd", which makes the other use look sloppy. I changed it to "in the initrd" everywhere in that file.
> Man page: systemd.directives.7
> Issue: Why are these two quoted (but not others)?
>
> "B<\\*(Aqh\\*(Aq>"
>
> B<\\*(Aqs\\*(Aq>"
>
> "B<\\*(Aqy\\*(Aq>"
This is autogenerated from files… We use slightly different markup in different files, and it's just too hard to make it consistent. We gave up on this.
> Man page: systemd.exec.5
> Issue 1: B<at>(1p) → B<at>(1)
> Issue 2: B<crontab>(1p) → B<crontab>(1)
Fixed.
> Man page: systemd.exec.5
> Issue: B<select()> → B<select>(2)
Fixed.
> Man page: systemd.exec.5
> Issue: qemu → B<qemu>(1)
The man page doesn't seem to be in any of the canonical places on the web.
I added a link to online docs.
> Man page: systemd.exec.5
> Issue: variable → variables
Seems to be fixed already.
> Man page: systemd-integritysetup-generator.8
> Issue: systemd-integritysetup-generator → B<systemd-integritysetup-generator>
I changed <filename> to <command>.
> Man page: systemd-integritysetup-generator.8
> Issue: superfluous comma at the end
Already fixed.
> Man page: systemd-measure.1
> Issue: (see B<--pcr-bank=>) below → (see B<--pcr-bank=> below)
Reworded.
> Man page: systemd-measure.1
> Issue: =PATH> → =>I<PATH>
Fixed.
> Man page: systemd-measure.1.po
> Issue: B<--bank=DIGEST> → B<--bank=>I<DIGEST>
Fixed.
> Man page: systemd.netdev.5
> Issue: os the → on the
Appears to have been fixed already.
> Man page: systemd.netdev.5
> Issue: Onboard → On-board (as in previous string)
Updated.
> Man page: systemd.network.5
> Issue: B<systemd-networkd> -> B<systemd-networkd>(8)
First reference does this, subsequent do not.
> Man page: systemd.network.5
> Issue: B<netlabelctl> → B<netlabelctl>(8)
First reference does this, subsequent do not.
> Man page: systemd.network.5
> Issue: Missing verb (aquired? configured?) in the half sentence starting with "or by a "
I dropped the comma.
> Man page: systemd-nspawn.1
> Issue: All host users outside of that range → All other host users
Reworded.
> # FIXME no effect → no effect\\&.
> #. type: Plain text
> #: archlinux debian-unstable fedora-rawhide mageia-cauldron opensuse-tumbleweed
> msgid ""
> "Whichever ID mapping option is used, the same mapping will be used for users "
> "and groups IDs\\&. If B<rootidmap> is used, the group owning the bind "
> "mounted directory will have no effect"
A period is added. Not sure if there's some other issue.
> Man page: systemd-oomd.service.8
> Issue: B<systemd> → B<systemd>(1)
Done.
> Man page: systemd.path.5
> Issue 1: B<systemd.exec>(1) → B<systemd.exec>(5)
> Issue 2: This section does not (yet?) exist
Fixed.
> Man page: systemd-pcrphase.service.8
> Issue 1: indicate phases into TPM2 PCR 11 ??
> Issue 2: Colon at the end of the paragraph?
Fixed.
> Man page: systemd-pcrphase.service.8
> Issue: final boot phase → final shutdown phase?
Updated.
> Man page: systemd-pcrphase.service.8
> Issue: for the the → for the
Fixed tree-wide.
> Man page: systemd-portabled.service.8
> Issue: In systemd-portabled.service(8): Portable Services Documentation
Updated.
> Man page: systemd-pstore.service.8
> Issue: Here and the following paragraphs: . → \\&. // Upstream: What does this comment mean? // You normally write \\&. for a full dot (full stop etc.); here you write only "." (i.e. a plain dot).
>
> "and we look up \"localhost\", nss-dns will send the following queries to "
> "systemd-resolved listening on 127.0.0.53:53: first \"localhost.foobar.com\", "
> "then \"localhost.barbar.com\", and finally \"localhost\". If (hopefully) the "
> "first two queries fail, systemd-resolved will synthesize an answer for the "
> "third query."
Looks all OK to me.
> Man page: systemd.resource-control.5
> Issue: Missing closing bracket after link to Control Groups version 1
Fixed.
> Man page: systemd-sysext.8
> Issue: In systemd-portabled.service(8): Portable Services Documentation
Updated.
> Man page: systemd.timer.5
> Issue 1: B<systemd.exec>(1) → B<systemd.exec>(5)
> Issue 2: This section does not (yet?) exist
Fixed.
> Man page: systemd.unit.5
> Issue: that is → that are
Fixed.
> Man page: systemd-veritysetup-generator.8
> Issue: systemd-veritysetup-generator → B<systemd-veritysetup-generator>
>
> "systemd-veritysetup-generator implements B<systemd.generator>(7)\\&."
>
> "systemd-veritysetup-generator understands the following kernel command line "
> "parameters:"
Updated.
> Man page: systemd-volatile-root.service.8
> Issue: initrdyes → Initrd
Fixed.
> Man page: sysupdate.d.5
> Issue: : → \\&. (As above in TRANSFER)
Updated.
> Man page: sysupdate.d.5
> Issue: some → certain
Updated.
> Man page: sysupdate.d.5
> Issue 1: i\\&.e\\& → I\\&.e\\&
Fixed.
> Issue 2: the image → the system
"image" seems correct.
> Man page: tmpfiles.d.5
> Issue: systemd-tmpfiles → B<systemd-tmpfiles>(8)
Updated.
2023-01-11 15:45:59 +00:00
|
|
|
<para>To test, use <command>glibc</command>'s
|
|
|
|
<citerefentry project='man-pages'><refentrytitle>getent</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
|
|
|
tool:</para>
|
2013-01-05 17:39:09 +00:00
|
|
|
|
2015-02-04 02:14:13 +00:00
|
|
|
<programlisting>$ getent ahosts `hostname`
|
|
|
|
::1 STREAM omega
|
|
|
|
::1 DGRAM
|
|
|
|
::1 RAW
|
2013-01-05 17:39:09 +00:00
|
|
|
127.0.0.2 STREAM
|
|
|
|
127.0.0.2 DGRAM
|
2014-02-14 14:56:19 +00:00
|
|
|
127.0.0.2 RAW</programlisting>
|
2013-01-05 17:39:09 +00:00
|
|
|
|
2014-08-03 05:11:12 +00:00
|
|
|
<para>In this case, the local hostname is <varname>omega</varname>.</para>
|
2013-01-05 17:39:09 +00:00
|
|
|
|
2015-02-04 02:14:13 +00:00
|
|
|
</refsect1>
|
2013-01-05 17:39:09 +00:00
|
|
|
|
2015-02-04 02:14:13 +00:00
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
2023-12-22 18:09:32 +00:00
|
|
|
<para><simplelist type="inline">
|
|
|
|
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
|
|
|
|
<member><citerefentry><refentrytitle>nss-systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
|
|
|
|
<member><citerefentry><refentrytitle>nss-resolve</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
|
|
|
|
<member><citerefentry><refentrytitle>nss-mymachines</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
|
|
|
|
<member><citerefentry project='man-pages'><refentrytitle>nsswitch.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
|
|
|
|
<member><citerefentry project='man-pages'><refentrytitle>getent</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
|
|
|
|
</simplelist></para>
|
2015-02-04 02:14:13 +00:00
|
|
|
</refsect1>
|
2013-01-05 17:39:09 +00:00
|
|
|
|
|
|
|
</refentry>
|